-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptionHandler.cs
More file actions
43 lines (41 loc) · 1.23 KB
/
Copy pathExceptionHandler.cs
File metadata and controls
43 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Text;
using Hedgey.Extensions;
using RxTelegram.Bot.Exceptions;
namespace Hedgey.Sirena;
static public class ExceptionHandler
{
static public void OnError(Exception exception)
{
var time = Shortucts.CurrentTimeLabel();
var current = exception;
Console.WriteLine(time + "EXCEPTION!!!");
int i = 0;
do
{
string? name = current.GetType().FullName;
StringBuilder builder = new StringBuilder($"<{i}> {name}: {current.Message}\n");
switch (current)
{
case ApiException apiException:
{
builder.Append($"Description: {apiException.Description}\n{current.StackTrace}");
Console.WriteLine(builder);
}
break;
case RequestValidationException validationException:
{
builder.AppendLine("validateion errors:");
foreach(var error in validationException.ValidationErrors)
builder.AppendLine(error.GetMessage);
Console.WriteLine(builder);
}
break;
default: Console.WriteLine(builder.AppendLine(current.StackTrace)); break;
}
current = current.InnerException;
++i;
builder.Clear();
}
while (current != null);
}
}