Class CustomErrorHandlingLaunchDelegate

  • All Implemented Interfaces:
    org.eclipse.debug.core.model.ILaunchConfigurationDelegate, org.eclipse.debug.core.model.ILaunchConfigurationDelegate2
    Direct Known Subclasses:
    AbstractRuntimeDebugAwareLaunchDelegate

    public abstract class CustomErrorHandlingLaunchDelegate
    extends org.eclipse.debug.core.model.LaunchConfigurationDelegate
    LaunchConfigurationDelegate with custom error handling.

    Error handling for this delegate launch process can be configured by error code with specific status handling. By default, error dialog with error stack trace will be shown.

    • Field Summary

      • Fields inherited from class org.eclipse.debug.core.model.LaunchConfigurationDelegate

        complileErrorProjectPromptStatus, complileErrorPromptStatus, promptStatus, saveScopedDirtyEditors, switchToDebugPromptStatus
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract void doLaunch​(org.eclipse.debug.core.ILaunchConfiguration configuration, String mode, org.eclipse.debug.core.ILaunch launch, org.eclipse.core.runtime.IProgressMonitor monitor)
      Launches the provided configuration in the specified mode, contributing debug targets and/or processes to the provided launch object.
      protected int errorCode()
      Returns error code of status handler, that will perform error handling of this launch delegate.
      protected String errorMessage​(Exception cause)
      Returns error message on default status handling error dialog.
      protected void handleError​(Exception e, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.debug.core.ILaunch launch)
      Handles the provided exception with associated status handler.
      protected void handleErrorStatus​(org.eclipse.core.runtime.IStatus status, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.debug.core.ILaunch launch)
      Handles the provided error status with associated status handler and removes current launch.
      protected <T> T handleStatus​(org.eclipse.core.runtime.IStatus status, Object source)
      Handles the provided status with associated status handler.
      protected org.eclipse.core.runtime.IStatus isValid​(org.eclipse.debug.core.ILaunchConfiguration configuration, String mode)
      Checks whether the provided launch configuration is valid.
      void launch​(org.eclipse.debug.core.ILaunchConfiguration configuration, String mode, org.eclipse.debug.core.ILaunch launch, org.eclipse.core.runtime.IProgressMonitor monitor)
      .
      protected boolean needHandling​(org.eclipse.debug.core.ILaunchConfiguration configuration, String mode, org.eclipse.debug.core.ILaunch launch, org.eclipse.core.runtime.IProgressMonitor monitor)
      Returns whether current launch needs custom handling.
      boolean preLaunchCheck​(org.eclipse.debug.core.ILaunchConfiguration configuration, String mode, org.eclipse.core.runtime.IProgressMonitor monitor)  
      protected void removeLaunch​(org.eclipse.debug.core.ILaunch launch)
      Remove launch from currenct debug platfrom launches.
      • Methods inherited from class org.eclipse.debug.core.model.LaunchConfigurationDelegate

        addReferencedProjects, buildForLaunch, buildProjects, computeBuildOrder, computeReferencedBuildOrder, existsProblems, finalLaunchCheck, getBreakpoints, getBuildOrder, getLaunch, getProjectsForProblemSearch, isLaunchProblem, saveBeforeLaunch
      • Methods inherited from interface org.eclipse.debug.core.model.ILaunchConfigurationDelegate

        showCommandLine
    • Constructor Detail

      • CustomErrorHandlingLaunchDelegate

        public CustomErrorHandlingLaunchDelegate()
    • Method Detail

      • launch

        public final void launch​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                 String mode,
                                 org.eclipse.debug.core.ILaunch launch,
                                 org.eclipse.core.runtime.IProgressMonitor monitor)
                          throws org.eclipse.core.runtime.CoreException
        .

        Should not be referenced by clients. Use doLaunch(ILaunchConfiguration, String, ILaunch, IProgressMonitor) instead.

        Throws:
        org.eclipse.core.runtime.CoreException
      • preLaunchCheck

        public boolean preLaunchCheck​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                      String mode,
                                      org.eclipse.core.runtime.IProgressMonitor monitor)
                               throws org.eclipse.core.runtime.CoreException
        Specified by:
        preLaunchCheck in interface org.eclipse.debug.core.model.ILaunchConfigurationDelegate2
        Overrides:
        preLaunchCheck in class org.eclipse.debug.core.model.LaunchConfigurationDelegate
        Throws:
        org.eclipse.core.runtime.CoreException
      • doLaunch

        public abstract void doLaunch​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                      String mode,
                                      org.eclipse.debug.core.ILaunch launch,
                                      org.eclipse.core.runtime.IProgressMonitor monitor)
                               throws org.eclipse.core.runtime.CoreException
        Launches the provided configuration in the specified mode, contributing debug targets and/or processes to the provided launch object.
        Parameters:
        configuration - the configuration to launch, cannot be null
        mode - the mode in which to launch, one of the mode constants defined by the ILaunchManager
        monitor - progress monitor, or null progress monitor, or null.
        launch - the launch object to contribute processes and debug targets to, cannot be null
        Throws:
        org.eclipse.core.runtime.CoreException - if launching fails
      • needHandling

        protected boolean needHandling​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                       String mode,
                                       org.eclipse.debug.core.ILaunch launch,
                                       org.eclipse.core.runtime.IProgressMonitor monitor)
        Returns whether current launch needs custom handling. Default implementation always returns true.
        Parameters:
        configuration - the configuration to launch, cannot be null
        mode - the mode in which to launch, one of the mode constants defined by the ILaunchManager
        monitor - progress monitor, or null progress monitor, or null.
        launch - the launch object to contribute processes and debug targets to, cannot be null
        Returns:
        whether current launch needs custom handling
      • errorCode

        protected int errorCode()
        Returns error code of status handler, that will perform error handling of this launch delegate.
        By default, returns status handler code, that will show error stack trace.
        Returns:
        error code of status handler, that will perform error handling of this launch delegate
      • errorMessage

        protected String errorMessage​(Exception cause)
        Returns error message on default status handling error dialog. Subclass may override.
        Parameters:
        cause - the cause exception, cannot be null
        Returns:
        error message on default status handling error dialog, never null
      • isValid

        protected org.eclipse.core.runtime.IStatus isValid​(org.eclipse.debug.core.ILaunchConfiguration configuration,
                                                           String mode)
                                                    throws org.eclipse.core.runtime.CoreException
        Checks whether the provided launch configuration is valid. Default implementation returns OK_STATUS.

        Returning status will be handled by the default Eclipse Debug Platform status handlers (if status severity will be not OK).

        Parameters:
        configuration - launch configuration to validate, cannot be null
        mode - the mode in which to launch, one of the mode constants defined by ILaunchManager
        Returns:
        the status of launch configuration correctness: whether the provided launch configuration is valid, never null
        Throws:
        org.eclipse.core.runtime.CoreException - if validation fails
        See Also:
        IErrorCodes
      • handleError

        protected void handleError​(Exception e,
                                   org.eclipse.core.runtime.IProgressMonitor monitor,
                                   org.eclipse.debug.core.ILaunch launch)
                            throws org.eclipse.core.runtime.CoreException
        Handles the provided exception with associated status handler.
        Parameters:
        e - exception to handle, cannot be null
        monitor - progress monitor to report progress to, cannot be null
        launch - the launch object to contribute processes and debug targets to, cannot be null
        Throws:
        org.eclipse.core.runtime.CoreException - if status handle failed
      • handleStatus

        protected <T> T handleStatus​(org.eclipse.core.runtime.IStatus status,
                                     Object source)
                              throws org.eclipse.core.runtime.CoreException
        Handles the provided status with associated status handler.
        Parameters:
        status - the handling status, cannot be null
        source - the source to handle status with, cannot be null
        Returns:
        an object representing the resolution of the status or null if not needed by the status handler
        Throws:
        org.eclipse.core.runtime.CoreException - if status handle failed
      • handleErrorStatus

        protected void handleErrorStatus​(org.eclipse.core.runtime.IStatus status,
                                         org.eclipse.core.runtime.IProgressMonitor monitor,
                                         org.eclipse.debug.core.ILaunch launch)
                                  throws org.eclipse.core.runtime.CoreException
        Handles the provided error status with associated status handler and removes current launch. The provided status code will be ignored.
        Parameters:
        status - the status to handle, cannot be null
        monitor - the progress monitor to report progress to, cannot be null
        launch - the launch object to contribute processes and debug targets to, cannot be null
        Throws:
        org.eclipse.core.runtime.CoreException - if status handle failed
      • removeLaunch

        protected void removeLaunch​(org.eclipse.debug.core.ILaunch launch)
        Remove launch from currenct debug platfrom launches. Cleints may use if launch actually does not produce any system or virtual processes.
        Parameters:
        launch - the launch to remove, cannot be null