Exposes Pretty property of CommandAppException

If a user is propagating the exceptions we aren't going to automatically display them. They might still want to get this exception message and use it, so we'll make it publicly available.
This commit is contained in:
Phil Scott 2021-04-23 09:48:19 -04:00 committed by Patrik Svensson
parent 8d67c0a6b4
commit 01f707c78d
2 changed files with 13 additions and 1 deletions

View File

@ -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)

View File

@ -8,7 +8,10 @@ namespace Spectre.Console.Cli
/// </summary>
public abstract class CommandAppException : Exception
{
internal IRenderable? Pretty { get; }
/// <summary>
/// Gets the pretty formatted exception message.
/// </summary>
public IRenderable? Pretty { get; }
internal virtual bool AlwaysPropagateWhenDebugging => false;