WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
ExceptionExtensions.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Diagnostics;
6 
7 
8 public static class ExceptionExtensions
9 {
10  public static List<string> GetNestedMessages(this Exception E)
11  {
12  List<string> L = new List<string>();
13  L.Add(E.Message);
14  if (E.InnerException != null)
15  {
16  L.AddRange(GetNestedMessages(E.InnerException));
17  }
18  return L;
19  }
20 
21  public static string GetFullExceptionDetails(this Exception E)
22  {
23  StringBuilder SB = new StringBuilder();
24 
25 
26  SB.AppendLine("Message: {0} --> {1}".Build(E.GetType().Name, E.Message));
27 
28  SB.AppendLine("Thread: {0}".Build(System.Threading.Thread.CurrentThread.Name));
29  SB.AppendLine("Source: {0}".Build(E.Source));
30 
31 
32  foreach (string S in E.StackTrace.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
33  {
34  SB.AppendLine("Stacktrace: {0}".Build(S));
35  }
36 
37  if (E.TargetSite != null)
38  {
39  SB.AppendLine("Targetsite: {0}".Build(E.TargetSite.ToString()));
40  }
41 
42  try
43  {
44  // Get stack trace for the exception with source file information
45  StackTrace ST = new StackTrace(E, true);
46  // Get the top stack frame
47  StackFrame Frame = ST.GetFrame(0);
48 
49  int Line = Frame.GetFileLineNumber();
50  string ExceptionFilename = Frame.GetFileName();
51 
52  SB.AppendLine("Location: LineNr {0} in {1]".Build(Line, ExceptionFilename));
53  }
54  catch { }
55 
56 
57  //Output inner exceptions
58  Exception EInner = E;
59  int Level = 1;
60  while (EInner.InnerException != null)
61  {
62  EInner = EInner.InnerException;
63  SB.AppendLine("InnerException {0}: {1} --> {2}".Build(Level, EInner.GetType().Name, EInner.Message));
64  Level++;
65 
66  if (Level > 30)
67  {
68  break;
69  }
70  }
71 
72 
73  return SB.ToString();
74  }
75 
76 
77 
78 }
79 
Animation steps though frames of the source image (this mainly for animated gifs).