-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathStackTracesOhMyExtensions.cs
58 lines (51 loc) · 1.8 KB
/
StackTracesOhMyExtensions.cs
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.IO;
using System.Threading.Tasks;
static class StackTracesOhMyExtensions
{
public static async Task PrintStackTrace(this StackTracesOhMy runnable, Func<Task> function)
{
try
{
await function();
}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
}
public static async Task Level2to6(this StackTracesOhMy runnable)
{
await Level2(runnable);
}
static async Task Level2(StackTracesOhMy runnable)
{
await Level3(runnable);
}
static async Task Level3(StackTracesOhMy runnable)
{
await Level4(runnable);
}
static async Task Level4(StackTracesOhMy runnable)
{
await Level5(runnable);
}
static async Task Level5(StackTracesOhMy runnable)
{
await runnable.Level6();
}
public static void Explain(this StackTracesOhMy runnable, TextWriter writer)
{
writer.WriteLine(@"
- With .NET Core 2.1 and later finally readable stack traces
```
at StackTracesOhMy.Level6() in C:\p\Async.Netcore\StackTracesOhMy.cs:line 19
at StackTracesOhMyExtensions.Level5(StackTracesOhMy runnable) in C:\p\Async.Netcore\StackTracesOhMyExtensions.cs:line 41
at StackTracesOhMyExtensions.Level4(StackTracesOhMy runnable) in C:\p\Async.Netcore\StackTracesOhMyExtensions.cs:line 36
at StackTracesOhMyExtensions.Level3(StackTracesOhMy runnable) in C:\p\Async.Netcore\StackTracesOhMyExtensions.cs:line 31
at StackTracesOhMyExtensions.Level2(StackTracesOhMy runnable) in C:\p\Async.Netcore\StackTracesOhMyExtensions.cs:line 26
at StackTracesOhMyExtensions.Level2to6(StackTracesOhMy runnable) in C:\p\Async.Netcore\StackTracesOhMyExtensions.cs:line 21
```
");
}
}