Implement more flexible error handling
- Add exception handling around new interface CommandExceptionResolver which allows to define a chain of resolvers to process errors before exception is bubbled up to result handlers. - Will be foundation to add more sophisticated error handling features compared to what spring itself have for rest layer. - Resolver returns CommandHandlingResult holder which further can be used to make a choice what to print into console and if spesific exit code should be used in non-interactive mode. - Exception handling can be defined globally and per command giving a change for user to customise i.e. error thrown by parser. - CommandParserExceptionResolver replaces CommandParserExceptionsExceptionResultHandler and provides more meaninful message for missing options. - Fixes #503
This commit is contained in:
@@ -23,7 +23,7 @@ describe('e2e commands exit-code', () => {
|
||||
cli.run();
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Missing option')]));
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Missing mandatory option')]));
|
||||
});
|
||||
await expect(cli.exitCode()).resolves.toBe(2);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user