forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptionUtils.cs
48 lines (41 loc) · 1.31 KB
/
ExceptionUtils.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
using System;
using System.Collections;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace GitCommands
{
public static class ExceptionUtils
{
public static void ShowException(Exception e)
{
ShowException(e, true);
}
public static void ShowException(Exception e, bool canIgnore)
{
ShowException(e, string.Empty, canIgnore);
}
public static void ShowException(Exception e, string info)
{
ShowException(e, info, true);
}
public static void ShowException(Exception e, string info, bool canIgnore)
{
if (!(canIgnore && IsIgnorable(e)))
MessageBox.Show(string.Join(Environment.NewLine + Environment.NewLine, info, e.ToStringWithData()));
}
public static bool IsIgnorable(Exception e)
{
return e is ThreadAbortException;
}
public static string ToStringWithData(this Exception e)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(e.ToString());
sb.AppendLine();
foreach(DictionaryEntry entry in e.Data)
sb.AppendLine(entry.Key + " = " + entry.Value);
return sb.ToString();
}
}
}