Last active
August 29, 2015 14:04
-
-
Save UltraSabreman/0918e7aaf6453b18361f to your computer and use it in GitHub Desktop.
Dumps an C# exception to the console in a some-what formatted fasion. (Uses my varardic print function).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void DumpException(Exception e) { | |
Func<int, String> getEquals = (count) => { | |
String s = ""; | |
for (int i = 0; i < count; i++) | |
s += "="; | |
return s; | |
}; | |
PrintLine(ConsoleColor.White, ConsoleColor.Red, "====EXCEPTION===="); | |
PrintLine(ConsoleColor.White, "=MSG: ", ConsoleColor.Red, e.Message); | |
PrintLine(ConsoleColor.White, "=SRC: ", ConsoleColor.Red, e.Source); | |
PrintLine(ConsoleColor.White, "=TGT: ", ConsoleColor.Red, e.TargetSite); | |
PrintLine(ConsoleColor.White, "=ST : ", ConsoleColor.Red, e.StackTrace); | |
e = e.InnerException; | |
int ind = 1; | |
while (e != null) { | |
String eq = getEquals(ind++); | |
PrintLine(ConsoleColor.White, ConsoleColor.Red, eq + "===EXCEPTION===="); | |
PrintLine(ConsoleColor.White, eq + "MSG: ", ConsoleColor.Red, e.Message); | |
PrintLine(ConsoleColor.White, eq + "SRC: ", ConsoleColor.Red, e.Source); | |
PrintLine(ConsoleColor.White, eq + "TGT: ", ConsoleColor.Red, e.TargetSite); | |
PrintLine(ConsoleColor.White, eq + "ST : ", ConsoleColor.Red, e.StackTrace); | |
e = e.InnerException; | |
} | |
PrintLine(ConsoleColor.White, ConsoleColor.Red, "================="); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment