spectre.console/examples/Console/Showcase/ExceptionGenerator.cs
2021-04-09 22:01:05 +02:00

32 lines
666 B
C#

using System;
using Spectre.Console;
namespace Showcase
{
public static class ExceptionGenerator
{
public static Exception GenerateException()
{
try
{
SomeOperation();
throw new InvalidOperationException();
}
catch (Exception ex)
{
return ex;
}
}
private static void SomeOperation()
{
SomeOperationGoingWrong();
}
private static void SomeOperationGoingWrong()
{
throw new InvalidOperationException("Something went very wrong!");
}
}
}