mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
30 lines
565 B
C#
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!");
|
|
}
|
|
}
|