public ToStringBuilder ( StringBuilder b, string prefix ) : void | ||
b | StringBuilder | The StringBuilder to write to. |
prefix | string | Prefix that will appear at the start of each line. |
return | void |
static string DumpErrorText(DateTimeStamp logTime, string text, LogLevel level, CKTrait tags, CKExceptionData exData) { StringBuilder buffer = CreateHeader(logTime, text, level, tags); if (exData != null) { exData.ToStringBuilder(buffer, String.Empty); } WriteFooter(level, buffer); return(buffer.ToString()); }
/// <summary> /// Writes the exception data as a readable block of text into a <see cref="StringBuilder"/>. /// </summary> /// <param name="b">The StringBuilder to write to.</param> /// <param name="prefix">Prefix that will appear at the start of each line.</param> public void ToStringBuilder(StringBuilder b, string prefix) { if (prefix == null) { prefix = string.Empty; } if (prefix.Length == 0 && _toString != null) { b.Append(_toString); return; } b.Append(prefix); b.Append(" ┌──────────────────────────■ Exception: "); b.Append(_exceptionTypeName); b.Append(" ■──────────────────────────"); b.AppendLine(); Debug.Assert(("──────────────────────────■ Exception: " + " ■──────────────────────────").Length == 39 + 28); int lenHeader = _exceptionTypeName.Length + 39 + 28; string locPrefix = prefix + " | "; AppendField(b, locPrefix, "Message", _message); if (_stackTrace != null) { AppendField(b, locPrefix, "Stack", _stackTrace); } if (!string.IsNullOrEmpty(_fileName)) { AppendField(b, locPrefix, "FileName", _fileName); } if (_detailedInfo != null) { AppendField(b, locPrefix, "Details", _detailedInfo); } if (_loaderExceptions != null) { b.Append(locPrefix) .Append(" ┌──────────────────────────■ [Loader Exceptions] ■──────────────────────────") .AppendLine(); foreach (var item in _loaderExceptions) { item.ToStringBuilder(b, locPrefix + " | "); } b.Append(locPrefix) .Append(" └─────────────────────────────────────────────────────────────────────────") .AppendLine(); } // The InnerException of an aggregated exception is the same as the first of it InnerExceptionS. // (The InnerExceptionS are the contained/aggregated exceptions of the AggregatedException object.) // This is why, if we are on an AggregatedException we do not follow its InnerException. if (_aggregatedExceptions != null) { b.Append(locPrefix) .Append(" ┌──────────────────────────■ [Aggregated Exceptions] ■──────────────────────────") .AppendLine(); foreach (var item in _aggregatedExceptions) { item.ToStringBuilder(b, locPrefix + " | "); } b.Append(locPrefix) .Append(" └─────────────────────────────────────────────────────────────────────────") .AppendLine(); } else if (_innerException != null) { b.Append(locPrefix) .Append(" ┌──────────────────────────■ [Inner Exception] ■──────────────────────────") .AppendLine(); _innerException.ToStringBuilder(b, locPrefix + " | "); b.Append(locPrefix) .Append(" └─────────────────────────────────────────────────────────────────────────") .AppendLine(); } b.Append(prefix) .Append(" └─────────────────────────────────────────────────────────────────────────") .AppendLine(); }
static string DumpErrorText( DateTimeStamp logTime, string text, LogLevel level, CKTrait tags, CKExceptionData exData ) { StringBuilder buffer = CreateHeader( logTime, text, level, tags ); if( exData != null ) exData.ToStringBuilder( buffer, String.Empty ); WriteFooter( level, buffer ); return buffer.ToString(); }