Exceptions
1) Call stack context From SO. In short, throw usually preserves the stack trace of the original thrown exception, but only if the exception didn’t occur in the current stack frame (i.e. method). ExceptionCallStackTest.cs gist | MSTest raw file
//To preserve the full call stack information, you need to use the following method:
private static void PreserveStackTrace(Exception exception) {
MethodInfo preserveStackTrace = typeof(Exception).GetMethod("InternalPreserveStackTrace", BindingFlags.Instance | BindingFlags.NonPublic);
preserveStackTrace.Invoke(exception, null);
}
2) How to decorate an exception: Use the public virtual IDictionary Data { get; }
property. Gets a collection of key/value pairs that provide additional user-defined information about the exception. msdn