internal static void ExtractStringFromExceptionInternal(object exceptiono, out string message, out string stackTrace) { bool flag = exceptiono == null; if (flag) { throw new ArgumentException("ExtractStringFromExceptionInternal called with null exception"); } Exception ex = exceptiono as Exception; bool flag2 = ex == null; if (flag2) { throw new ArgumentException("ExtractStringFromExceptionInternal called with an exceptoin that was not of type System.Exception"); } StringBuilder stringBuilder = new StringBuilder((ex.StackTrace == null) ? 512 : (ex.StackTrace.Length * 2)); message = ""; string text = ""; while (ex != null) { bool flag3 = text.Length == 0; if (flag3) { text = ex.StackTrace; } else { text = ex.StackTrace + "\n" + text; } string text2 = ex.GetType().Name; string text3 = ""; bool flag4 = ex.Message != null; if (flag4) { text3 = ex.Message; } bool flag5 = text3.Trim().Length != 0; if (flag5) { text2 += ": "; text2 += text3; } message = text2; bool flag6 = ex.InnerException != null; if (flag6) { text = "Rethrow as " + text2 + "\n" + text; } ex = ex.InnerException; } stringBuilder.Append(text + "\n"); StackTrace stackTrace2 = new StackTrace(1, true); stringBuilder.Append(StackTraceUtility.ExtractFormattedStackTrace(stackTrace2)); stackTrace = stringBuilder.ToString(); }
internal static void ExtractStringFromExceptionInternal(object exceptiono, out string message, out string stackTrace) { if (exceptiono == null) { throw new ArgumentException("ExtractStringFromExceptionInternal called with null exception"); } Exception exception = exceptiono as Exception; if (exception == null) { throw new ArgumentException("ExtractStringFromExceptionInternal called with an exceptoin that was not of type System.Exception"); } StringBuilder stringBuilder = new StringBuilder(exception.StackTrace != null ? exception.StackTrace.Length * 2 : 512); message = string.Empty; string str1 = string.Empty; for (; exception != null; exception = exception.InnerException) { str1 = str1.Length != 0 ? exception.StackTrace + "\n" + str1 : exception.StackTrace; string str2 = exception.GetType().Name; string str3 = string.Empty; if (exception.Message != null) { str3 = exception.Message; } if (str3.Trim().Length != 0) { str2 = str2 + ": " + str3; } message = str2; if (exception.InnerException != null) { str1 = "Rethrow as " + str2 + "\n" + str1; } } stringBuilder.Append(str1 + "\n"); StackTrace stackTrace1 = new StackTrace(1, true); stringBuilder.Append(StackTraceUtility.ExtractFormattedStackTrace(stackTrace1)); stackTrace = stringBuilder.ToString(); }
public unsafe static string ExtractStackTrace() { int num = 16384; byte * ptr = stackalloc byte[num]; int num2 = Debug.ExtractStackTraceNoAlloc(ptr, num, StackTraceUtility.projectFolder); bool flag = num2 > 0; string result; if (flag) { result = new string((sbyte *)ptr, 0, num2, Encoding.UTF8); } else { StackTrace stackTrace = new StackTrace(1, true); string text = StackTraceUtility.ExtractFormattedStackTrace(stackTrace); result = text; } return(result); }
public static string ExtractStackTrace() { StackTrace stackTrace = new StackTrace(1, true); return(StackTraceUtility.ExtractFormattedStackTrace(stackTrace).ToString()); }