Files
spectreconsole-examples/examples/Console/Showcase/ExceptionGenerator.cs
Patrik Svensson a3cc9f5f72 Initial commits
2024-08-05 21:20:18 +02:00

30 lines
549 B
C#

using System;
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!");
}
}