diff --git a/src/Spectre.Console.Testing/Cli/CommandAppTester.cs b/src/Spectre.Console.Testing/Cli/CommandAppTester.cs index 00d50806..4ad02764 100644 --- a/src/Spectre.Console.Testing/Cli/CommandAppTester.cs +++ b/src/Spectre.Console.Testing/Cli/CommandAppTester.cs @@ -53,6 +53,15 @@ namespace Spectre.Console.Testing } catch (T ex) { + if (ex is CommandAppException commandAppException && commandAppException.Pretty != null) + { + console.Write(commandAppException.Pretty); + } + else + { + console.WriteLine(ex.Message); + } + return new CommandAppFailure(ex, console.Output); } catch (Exception ex) diff --git a/src/Spectre.Console/Cli/CommandAppException.cs b/src/Spectre.Console/Cli/CommandAppException.cs index a1fd8df4..7d0ef6f1 100644 --- a/src/Spectre.Console/Cli/CommandAppException.cs +++ b/src/Spectre.Console/Cli/CommandAppException.cs @@ -8,7 +8,10 @@ namespace Spectre.Console.Cli /// public abstract class CommandAppException : Exception { - internal IRenderable? Pretty { get; } + /// + /// Gets the pretty formatted exception message. + /// + public IRenderable? Pretty { get; } internal virtual bool AlwaysPropagateWhenDebugging => false;