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();
}