public static string ExceptionDetails(System.Text.StringBuilder builder, System.Exception e)
builder.AppendLine("\n\n-----");
builder.AppendLine("Data:".PadRight(20) + e.Data);
builder.AppendLine("Message:".PadRight(20) + e.Message);
builder.AppendLine("StackTrace:".PadRight(17) + e.StackTrace);
builder.AppendLine("TargetSite:".PadRight(20) + e.TargetSite.ToString());
builder.AppendLine("-----");
ExceptionDetails(builder, e.InnerException);
return builder.ToString();
public static void Main()
throw new Exception("Some inner exception.");
throw new Exception("Some outer exception.", e);
var builder = new StringBuilder();
var details = ExceptionDetails(builder, e);
throw new Exception(details);