UnityEngine.StackTraceUtility.ExtractStringFromExceptionInternal C# (CSharp) Method

ExtractStringFromExceptionInternal() private method

private ExtractStringFromExceptionInternal ( object exceptiono, string &message, string &stackTrace ) : void
exceptiono object
message string
stackTrace string
return void
        internal static void ExtractStringFromExceptionInternal(object exceptiono, out string message, out string stackTrace)
        {
            if (exceptiono == null)
            {
                throw new ArgumentException("ExtractStringFromExceptionInternal called with null exception");
            }
            Exception innerException = exceptiono as Exception;
            if (innerException == null)
            {
                throw new ArgumentException("ExtractStringFromExceptionInternal called with an exceptoin that was not of type System.Exception");
            }
            StringBuilder builder = new StringBuilder((innerException.StackTrace != null) ? (innerException.StackTrace.Length * 2) : 0x200);
            message = "";
            string str = "";
            while (innerException != null)
            {
                if (str.Length == 0)
                {
                    str = innerException.StackTrace;
                }
                else
                {
                    str = innerException.StackTrace + "\n" + str;
                }
                string name = innerException.GetType().Name;
                string str3 = "";
                if (innerException.Message != null)
                {
                    str3 = innerException.Message;
                }
                if (str3.Trim().Length != 0)
                {
                    name = name + ": " + str3;
                }
                message = name;
                if (innerException.InnerException != null)
                {
                    str = "Rethrow as " + name + "\n" + str;
                }
                innerException = innerException.InnerException;
            }
            builder.Append(str + "\n");
            StackTrace trace = new StackTrace(1, true);
            builder.Append(ExtractFormattedStackTrace(trace));
            stackTrace = builder.ToString();
        }

Usage Example

コード例 #1
0
        public static string ExtractStringFromException(object exception)
        {
            string empty  = string.Empty;
            string empty2 = string.Empty;

            StackTraceUtility.ExtractStringFromExceptionInternal(exception, out empty, out empty2);
            return(empty + "\n" + empty2);
        }
All Usage Examples Of UnityEngine.StackTraceUtility::ExtractStringFromExceptionInternal