spectre.console/examples/Console/Showcase/ExceptionGenerator.cs
2021-12-22 08:51:17 -05:00

30 lines
565 B
C#

using System;
namespace Spectre.Console.Examples;
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!");
}
}