diff --git a/spring-shell-core/src/main/java/org/springframework/shell/result/CommandNotFoundResultHandler.java b/spring-shell-core/src/main/java/org/springframework/shell/result/CommandNotFoundResultHandler.java deleted file mode 100644 index 92fb3e43..00000000 --- a/spring-shell-core/src/main/java/org/springframework/shell/result/CommandNotFoundResultHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.shell.result; - -import org.jline.utils.AttributedString; -import org.jline.utils.AttributedStyle; - -import org.springframework.shell.CommandNotFound; -import org.springframework.shell.ResultHandler; -import org.springframework.stereotype.Component; - -/** - * Used when no command can be matched for user input. - * - * Simply prints an error message, without printing the exception class. - * - * @author Eric Bottard - */ -@Component -public class CommandNotFoundResultHandler extends TerminalAwareResultHandler { - - @Override - protected void doHandleResult(CommandNotFound result) { - terminal.writer().println(new AttributedString(result.getMessage(), - AttributedStyle.DEFAULT.foreground(AttributedStyle.RED)).toAnsi()); - terminal.writer().flush(); - - } -} diff --git a/spring-shell-core/src/main/java/org/springframework/shell/result/ThrowableResultHandler.java b/spring-shell-core/src/main/java/org/springframework/shell/result/ThrowableResultHandler.java index 68d46b8c..ff19902a 100644 --- a/spring-shell-core/src/main/java/org/springframework/shell/result/ThrowableResultHandler.java +++ b/spring-shell-core/src/main/java/org/springframework/shell/result/ThrowableResultHandler.java @@ -25,10 +25,13 @@ import org.springframework.context.annotation.Lazy; import org.springframework.shell.CommandRegistry; import org.springframework.shell.ResultHandler; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; /** * A {@link ResultHandler} that prints thrown exceptions messages in red. * + *

Also stores the last exception reported, so that details can be printed using a dedicated command.

+ * * @author Eric Bottard */ @Component @@ -47,7 +50,8 @@ public class ThrowableResultHandler extends TerminalAwareResultHandler