protected override void WriteExceptionProperties(Exception exception, TextWriter messageWriter)
        {
            base.WriteExceptionProperties(exception, messageWriter);

            var faultException = exception as FaultException;

            if (faultException != null)
                messageWriter
                    .WriteLineIf(faultException.Reason != null, "Reason: {0}", faultException.Reason)
                    .WriteLineIf(faultException.Code != null && faultException.Code.Name.IsNotNullOrWhiteSpace(),
                                 "Code: {0}", faultException.Code.Name)
                    .WriteLineIf(faultException.Action.IsNotNullOrWhiteSpace(), "Action: {0}", faultException.Action);
        }
        protected override void WriteExceptionProperties(Exception exception, TextWriter messageWriter)
        {
            base.WriteExceptionProperties(exception, messageWriter);

            var sqlException = exception as SqlException;

            if (sqlException != null)
                messageWriter
                    .WriteLineIf(sqlException.ErrorCode != 0, VariableFormatExpression, "ErrorCode", sqlException.ErrorCode)
                    .WriteLineIf(sqlException.Class != 0, VariableFormatExpression, "Class", sqlException.Class)
                    .WriteLineIf(sqlException.State != 0, VariableFormatExpression, "State", sqlException.State)
                    .WriteLineIf(sqlException.Number != 0, VariableFormatExpression, "Number", sqlException.Number)
                    .WriteLineIf(sqlException.LineNumber != 0, VariableFormatExpression, "LineNumber", sqlException.LineNumber)
                    .WriteLineIf(sqlException.Server.IsNotNullOrWhiteSpace(), VariableFormatExpression, "Server", sqlException.Server)
                    .WriteLineIf(sqlException.Procedure.IsNotNullOrWhiteSpace(), VariableFormatExpression, "Procedure", sqlException.Procedure);
        }
        protected virtual void WriteSourceAndStackTrace(Exception exception, TextWriter messageWriter)
        {
            #if !SILVERLIGHT
            messageWriter.WriteLineIf(exception.Source.IsNotNullOrWhiteSpace(), "Source: {0}", exception.Source);
            #endif

            if (exception.StackTrace.IsNotNullOrWhiteSpace())
            {
                messageWriter.WriteLine(exception.StackTrace);
                messageWriter.WriteLine();
            }
        }