Skip to content

No proper default exception handling in spring shell 4 #1272

@georgmittendorfer

Description

@georgmittendorfer

What?

If a command throws an exception I would assume that the exception message is printed as the default behavior.

Current behavior

If an exception is thrown the exception message is not printed:

shell:>some command --someOption TEST
Unable to run command some: null

Wanted behavior

The error message should contain the exception message, for example:

shell:>some command --someOption TEST
Unable to run command some: some error message

Alternatively it would be ok, if it was possible to define a default exception handler for all commands. It seems it is only possible to define a exitStatusExceptionMapper on command level. Otherwise it would be necessary to add try catch blocks to all commands only to print the exception error message.

Code references

Relevant code seems to be in InteractiveShellRunner:

catch (CommandExecutionException executionException) { // technical error
	Throwable cause = executionException.getCause();
	String errorMessage = "Unable to run command " + parsedInput.commandName();
	print(cause == null ? errorMessage : errorMessage + ": " + cause.getMessage());
        ...
}

cause.getMessage() seems to be null here. It would be better to print the root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions