Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32273

Refactor and unify issue handling in CLI commands

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • cli, core
    • None

      TL;DR;
      The aim of this JIRA is to start unification of an issue handling in CLI commands.

      Details:
      Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as @CLIMethod or extending hudson.cli.CLICommand class.

      @CLIMethod usually returns 1 in the case an issue occurred, similar situation in hudson.cli.CLICommand returns -1 to the shell.

      There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in hudson.cli.CLICommand.

      Currently we should use this semantic in CLI:

      • 0 means All right
      • -1 means An error occurred

      Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

      Update 07-Jan-2016 (WIP):

      TODO

      • Refactor core commands to use correct exception classes
      • Update javadoc for CLICommand#run
      • Unify the handling in CLIRegisterer

      Proposed a new unified scheme of exception raising, handling, reporting and error code returning:
      Update 12-Feb-2016: - Exception -> Throwable

      Exception name Meaning Correct usage Incorrect usage Processing Return code
      CmdLineException Wrong parameter,
      input value can't be decoded etc.
      CommandDuringBuild.java
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      • print usage help
      2
      IllegalStateException Can't continue due to an incorrect
      state of Jenkins instance, job, build etc.
      CommandDuringBuild.java
      comes from Jenkins.getActiveInstance()
      none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      4
      IllegalArgumentException Can't continue due to
      wrong input parameter (job doesn't exist etc.)
      CopyJobCommand.java
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      3
      AbortException Can't continue due to an other (rare) issue
      Note: Current usage of this exception is wrong,
      usually there should be IllegalState or CmdLine exception
      raised instead of this
      none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      5
      AccessDeniedException Not sufficent rights for requested action comes from checkPermission() none
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr
      6
      BadCredentialsException Bad credentials provided via the CLI N/A N/A
      • catch in CLICommand
      • print "\nERROR: " + cause message to stderr with HASH
      • log a cause (HASH included) with INFO level
      7
      Exception
      Throwable
      Any unknown issue occurred, just to report it for the record N/A N/A
      • catch in CLICommand
      • print "\nERROR: " + general message to stderr
      • log general message + exception with WARNING level
      • print stacktrace to stderr for further investigation
      1

          [JENKINS-32273] Refactor and unify issue handling in CLI commands

          Pavel Janoušek created issue -

          PR for the first step. This part is fully backward compatible.

          Pavel Janoušek added a comment - PR for the first step. This part is fully backward compatible.

          Effort continues with the code re-factorization of CLI commands re-implemented in CLI module already, plus fixes in their respective tests.

          If we want simplified, non-duplicated, easy to read code and in addition error/exception handling and reporting in one place, we can't be fully back-ward compatible here

          However I believe this change is worth and it is better for the future to do such an unification sooner than later.

          Pavel Janoušek added a comment - Effort continues with the code re-factorization of CLI commands re-implemented in CLI module already, plus fixes in their respective tests. If we want simplified, non-duplicated, easy to read code and in addition error/exception handling and reporting in one place, we can't be fully back-ward compatible here However I believe this change is worth and it is better for the future to do such an unification sooner than later.
          Oliver Gondža made changes -
          Description Original: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented in the core or in the CLI module (means extending class {{hudson.cli.CLICommand}}).

          In the core return code = 1. The same situation in CLI - return code = -1.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.
          New: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          In the core return code = 1. The same situation in CLI - return code = -1.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.
          Pavel Janoušek made changes -
          Description Original: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          In the core return code = 1. The same situation in CLI - return code = -1.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.
          New: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.
          Pavel Janoušek made changes -
          Description Original: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.
          New: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

          Update 01-07-2016 ({color:red}WIP{color}):
          Proposed a new unified scheme of exception raising, handling, reporting and error code returning:

          || Exaption name || Meaning || Correct usage || Incorrect ussage || Processing || Return code ||
          | CmdLineException | Wrong parameter,
          input value can't be decoded etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L75] | * [AddJobToViewCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/AddJobToViewCommand.java#L58-L59] -> IllegalStateException \\
          * [ConsoleCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/ConsoleCommand.java#L53] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalStateException | Can't continue due to an incorrect
          state of Jenkins instance, job, build etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L58] | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalArgumentException | Can't continue due to
          wrong input parameter (job doesn't exist etc.) | [CopyJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CopyJobCommand.java#L66] | * [CreateJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CreateJobCommand.java#L67] -> IllegalStateException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AbortException | Can't continue due to an other (rare) issue \\
          Note: Current usage of this exception is wrong,
          usually there should be IllegalState or CmdLine exception
          raised instead of this | none | * [BuildCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L129] -> CmdLineException \\
          * [InstallToolCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/InstallToolCommand.java#L76] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AccessDeniedException | Not sufficent rights for requested action | comes from checkPermission() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | BadCredentialsException | Bad credentials provided via the CLI | N/A | N/A | * catch in CLICommand \\
          * print cause message to stderr with an HASH
          * log a cause with INFO level | -1 |
          | Exception | Unknown issue occurred, just to report it fot the record | N/A | N/A | * catch in CLICommand \\
          * print general message to stderr
          * log general message with WARNING level
          * print stacktrace to stderr for further investigation | -1 |
          Pavel Janoušek made changes -
          Summary Original: Refactor error return code(s) in CLI commands New: Refactor and unify issue handling in CLI commands
          Pavel Janoušek made changes -
          Description Original: TL;DR;
          The aim of this JIRA is to start unification of error return codes from CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

          Update 01-07-2016 ({color:red}WIP{color}):
          Proposed a new unified scheme of exception raising, handling, reporting and error code returning:

          || Exaption name || Meaning || Correct usage || Incorrect ussage || Processing || Return code ||
          | CmdLineException | Wrong parameter,
          input value can't be decoded etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L75] | * [AddJobToViewCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/AddJobToViewCommand.java#L58-L59] -> IllegalStateException \\
          * [ConsoleCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/ConsoleCommand.java#L53] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalStateException | Can't continue due to an incorrect
          state of Jenkins instance, job, build etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L58] | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalArgumentException | Can't continue due to
          wrong input parameter (job doesn't exist etc.) | [CopyJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CopyJobCommand.java#L66] | * [CreateJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CreateJobCommand.java#L67] -> IllegalStateException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AbortException | Can't continue due to an other (rare) issue \\
          Note: Current usage of this exception is wrong,
          usually there should be IllegalState or CmdLine exception
          raised instead of this | none | * [BuildCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L129] -> CmdLineException \\
          * [InstallToolCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/InstallToolCommand.java#L76] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AccessDeniedException | Not sufficent rights for requested action | comes from checkPermission() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | BadCredentialsException | Bad credentials provided via the CLI | N/A | N/A | * catch in CLICommand \\
          * print cause message to stderr with an HASH
          * log a cause with INFO level | -1 |
          | Exception | Unknown issue occurred, just to report it fot the record | N/A | N/A | * catch in CLICommand \\
          * print general message to stderr
          * log general message with WARNING level
          * print stacktrace to stderr for further investigation | -1 |
          New: TL;DR;
          The aim of this JIRA is to start unification of an issue handling in CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

          Update 01-07-2016 ({color:red}WIP{color}):
          Proposed a new unified scheme of exception raising, handling, reporting and error code returning:

          || Exaption name || Meaning || Correct usage || Incorrect ussage || Processing || Return code ||
          | CmdLineException | Wrong parameter,
          input value can't be decoded etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L75] | * [AddJobToViewCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/AddJobToViewCommand.java#L58-L59] -> IllegalStateException \\
          * [ConsoleCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/ConsoleCommand.java#L53] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalStateException | Can't continue due to an incorrect
          state of Jenkins instance, job, build etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L58] | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalArgumentException | Can't continue due to
          wrong input parameter (job doesn't exist etc.) | [CopyJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CopyJobCommand.java#L66] | * [CreateJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CreateJobCommand.java#L67] -> IllegalStateException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AbortException | Can't continue due to an other (rare) issue \\
          Note: Current usage of this exception is wrong,
          usually there should be IllegalState or CmdLine exception
          raised instead of this | none | * [BuildCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L129] -> CmdLineException \\
          * [InstallToolCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/InstallToolCommand.java#L76] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AccessDeniedException | Not sufficent rights for requested action | comes from checkPermission() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | BadCredentialsException | Bad credentials provided via the CLI | N/A | N/A | * catch in CLICommand \\
          * print cause message to stderr with an HASH
          * log a cause with INFO level | -1 |
          | Exception | Unknown issue occurred, just to report it fot the record | N/A | N/A | * catch in CLICommand \\
          * print general message to stderr
          * log general message with WARNING level
          * print stacktrace to stderr for further investigation | -1 |
          Pavel Janoušek made changes -
          Description Original: TL;DR;
          The aim of this JIRA is to start unification of an issue handling in CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

          Update 01-07-2016 ({color:red}WIP{color}):
          Proposed a new unified scheme of exception raising, handling, reporting and error code returning:

          || Exaption name || Meaning || Correct usage || Incorrect ussage || Processing || Return code ||
          | CmdLineException | Wrong parameter,
          input value can't be decoded etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L75] | * [AddJobToViewCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/AddJobToViewCommand.java#L58-L59] -> IllegalStateException \\
          * [ConsoleCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/ConsoleCommand.java#L53] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalStateException | Can't continue due to an incorrect
          state of Jenkins instance, job, build etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L58] | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalArgumentException | Can't continue due to
          wrong input parameter (job doesn't exist etc.) | [CopyJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CopyJobCommand.java#L66] | * [CreateJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CreateJobCommand.java#L67] -> IllegalStateException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AbortException | Can't continue due to an other (rare) issue \\
          Note: Current usage of this exception is wrong,
          usually there should be IllegalState or CmdLine exception
          raised instead of this | none | * [BuildCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L129] -> CmdLineException \\
          * [InstallToolCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/InstallToolCommand.java#L76] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AccessDeniedException | Not sufficent rights for requested action | comes from checkPermission() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | BadCredentialsException | Bad credentials provided via the CLI | N/A | N/A | * catch in CLICommand \\
          * print cause message to stderr with an HASH
          * log a cause with INFO level | -1 |
          | Exception | Unknown issue occurred, just to report it fot the record | N/A | N/A | * catch in CLICommand \\
          * print general message to stderr
          * log general message with WARNING level
          * print stacktrace to stderr for further investigation | -1 |
          New: TL;DR;
          The aim of this JIRA is to start unification of an issue handling in CLI commands.

          Details:
          Currently there is a discrepancy between returned error codes if an issue occurred during execution. It depends on the fact whether the CLI command is implemented as {{@CLIMethod}} or extending {{hudson.cli.CLICommand}} class.

          {{@CLIMethod}} usually returns 1 in the case an issue occurred, similar situation in {{hudson.cli.CLICommand}} returns -1 to the shell.

          There is an ongoing effort to extract all CLI commands from the Core to CLI (see JENKINS-22969), so the discrepancy should be removed shortly and consistent error code definition should be set-up on one place only - in {{hudson.cli.CLICommand}}.

          Currently we should use this semantic in CLI:
          * 0 means All right
          * -1 means An error occurred

          Technically anything else than zero means an issue occurred. Later we can use more precisely defined error codes for the different issues if useful.

          Update 07-Jan-2016 ({color:red}WIP{color}):
          Proposed a new unified scheme of exception raising, handling, reporting and error code returning:

          || Exaption name || Meaning || Correct usage || Incorrect ussage || Processing || Return code ||
          | CmdLineException | Wrong parameter,
          input value can't be decoded etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L75] | * [AddJobToViewCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/AddJobToViewCommand.java#L58-L59] -> IllegalStateException \\
          * [ConsoleCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/ConsoleCommand.java#L53] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalStateException | Can't continue due to an incorrect
          state of Jenkins instance, job, build etc. | [CommandDuringBuild.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CommandDuringBuild.java#L58] \\
          comes from Jenkins.getActiveInstance() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | IllegalArgumentException | Can't continue due to
          wrong input parameter (job doesn't exist etc.) | [CopyJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CopyJobCommand.java#L66] | * [CreateJobCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/CreateJobCommand.java#L67] -> IllegalStateException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AbortException | Can't continue due to an other (rare) issue \\
          Note: Current usage of this exception is wrong,
          usually there should be IllegalState or CmdLine exception
          raised instead of this | none | * [BuildCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L129] -> CmdLineException \\
          * [InstallToolCommand.java|https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/InstallToolCommand.java#L76] -> IllegalArgumentException | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | AccessDeniedException | Not sufficent rights for requested action | comes from checkPermission() | none | * catch in CLICommand \\
          * print cause message to stderr | -1 |
          | BadCredentialsException | Bad credentials provided via the CLI | N/A | N/A | * catch in CLICommand \\
          * print cause message to stderr with an HASH
          * log a cause with INFO level | -1 |
          | Exception | Unknown issue occurred, just to report it fot the record | N/A | N/A | * catch in CLICommand \\
          * print general message to stderr
          * log general message with WARNING level
          * print stacktrace to stderr for further investigation | -1 |

          Pavel Janoušek added a comment - - edited

          During the investigation I've realized the particular exception is used differently (in completely different situation) in the different CLI commands or the very similar situation/issue is reported by raising a different exception class in the different CLI commands.

          For that reason I've created a new proposal for the unified scheme how to handle an exceptional situation/state, which exception should be raised, how it should be processed, reported and which return code should be returned back to the shell.

          Pavel Janoušek added a comment - - edited During the investigation I've realized the particular exception is used differently (in completely different situation) in the different CLI commands or the very similar situation/issue is reported by raising a different exception class in the different CLI commands. For that reason I've created a new proposal for the unified scheme how to handle an exceptional situation/state, which exception should be raised, how it should be processed, reported and which return code should be returned back to the shell.

            pajasoft Pavel Janoušek
            pajasoft Pavel Janoušek
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: