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