mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
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:
parent
8d67c0a6b4
commit
01f707c78d
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user