Skip to content

Exception handling APIs removed in 4.0 without replacement #1265

@ThomasVitale

Description

@ThomasVitale

In Spring Shell 3.4, I was using APIs such as CommandExceptionResolver to customise the way to handle exceptions. For example:

@Component
public class ArconiaCliExceptionResolver implements CommandExceptionResolver {

    @Override
    public CommandHandlingResult resolve(Exception ex) {
        if (ex instanceof ArconiaCliException arconiaCliException) {
            arconiaCliException.getTerminal().handleException(ex.getMessage(), ex);
            return CommandHandlingResult.empty();
        }

        var attributedStringBuilder = new AttributedStringBuilder();
        attributedStringBuilder.append(new AttributedString(ex.getMessage(), AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)));
        attributedStringBuilder.append("\n");
        var attributedString = attributedStringBuilder.toAttributedString().toAnsi();
        return CommandHandlingResult.of(attributedString);
    }

} 

In Spring Shell 4.0, the CommandExceptionResolver and related APIs have been removed. What is the replacement for customising exception handling? It would be great to include this breaking change in the v4 migration guide, including some hints on how to migrate existing exception handling logic in Spring Shell 3.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status/need-triageTeam needs to triage and take a first look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions