/// <summary> /// Log and throw the exception specified with a message string. /// </summary> /// <param name="ex">The exception instance.</param> /// <param name="message">The message string.</param> public static void LogAndThrowException( string message, Exception ex ) { ExceptionFormatter formatter = new ExceptionFormatter(); if ( message != null && message.Length > 0 ) { LogError( message + "\n" + formatter.GetMessage( ex ) ); } else { LogError( formatter.GetMessage( ex ) ); } throw ex; }
private void ReportUnknownException(Exception exception, LogEntry log) { try { NameValueCollection additionalInfo = new NameValueCollection(); additionalInfo.Add(ExceptionFormatter.Header, Resources.ProcessMessageFailed); additionalInfo.Add(Resources.ProcessMessageFailed2, string.Format(Resources.Culture, Resources.ProcessMessageFailed3, log.ToString())); ExceptionFormatter formatter = new ExceptionFormatter(additionalInfo, Resources.DistributorEventLoggerDefaultApplicationName); LogEntry reportingLogEntry = new LogEntry(); reportingLogEntry.Severity = TraceEventType.Error; reportingLogEntry.Message = formatter.GetMessage(exception); reportingLogEntry.EventId = LogWriterFailureEventID; structureHolder.ErrorsTraceSource.TraceData(reportingLogEntry.Severity, reportingLogEntry.EventId, reportingLogEntry); } catch (Exception ex) { instrumentationProvider.FireFailureLoggingErrorEvent(Resources.UnknownFailure, ex); } }