Index: OnlyOnceErrorHandler.cs =================================================================== --- OnlyOnceErrorHandler.cs (revision 405571) +++ OnlyOnceErrorHandler.cs (working copy) @@ -38,6 +38,7 @@ /// /// Nicko Cadell /// Gert Driesen + /// Ron Grabowski public class OnlyOnceErrorHandler : IErrorHandler { #region Public Instance Constructors @@ -82,15 +83,23 @@ /// The internal error code. /// /// - /// Prints the message and the stack trace of the exception on the standard - /// error output stream. + /// Sends the error information to 's Error method. /// /// public void Error(string message, Exception e, ErrorCode errorCode) - { - if (IsEnabled) + { + if (m_firstTime) { - LogLog.Error("[" + m_prefix + "] " + message, e); + m_enabledDate = DateTime.Now; + m_errorCode = errorCode; + m_exception = e; + m_message = message; + m_firstTime = false; + + if (LogLog.InternalDebugging && !LogLog.QuietMode) + { + LogLog.Error("[" + m_prefix + "] ErrorCode: " + errorCode.ToString() + ". " + message, e); + } } } @@ -106,11 +115,8 @@ /// /// public void Error(string message, Exception e) - { - if (IsEnabled) - { - LogLog.Error("[" + m_prefix + "] " + message, e); - } + { + Error(message, e, ErrorCode.GenericFailure); } /// @@ -125,10 +131,7 @@ /// public void Error(string message) { - if (IsEnabled) - { - LogLog.Error("[" + m_prefix + "] " + message); - } + Error(message, null, ErrorCode.GenericFailure); } #endregion Implementation of IErrorHandler @@ -142,38 +145,92 @@ /// first error delivered to the . /// /// - private bool IsEnabled + public bool IsEnabled { get { - // Allow first error message to be logged - if (m_firstTime) - { - m_firstTime = false; - return true; - } - - // Check if InternalDebugging is enabled - if (LogLog.InternalDebugging && !LogLog.QuietMode) - { - return true; - } - return false; + return m_firstTime; } } + /// + /// The date the first error that trigged this error handler occured. + /// + public DateTime EnabledDate + { + get { return m_enabledDate; } + set { m_enabledDate = value; } + } + + #region Public Instance Properties + + /// + /// The message from the first error that trigged this error handler. + /// + public string ErrorMessage + { + get { return m_message; } + set { m_message = value; } + } + + /// + /// The exception from the first error that trigged this error handler. + /// + /// + /// May be . + /// + public Exception Exception + { + get { return m_exception; } + set { m_exception = value; } + } + + /// + /// The error code from the first error that trigged this error handler. + /// + /// + /// Defaults to + /// + public ErrorCode ErrorCode + { + get { return m_errorCode; } + set { m_errorCode = value; } + } + + #endregion + #region Private Instance Fields /// + /// + /// + private DateTime m_enabledDate; + + /// /// Flag to indicate if it is the first error /// private bool m_firstTime = true; /// + /// The message recorded during the first error. + /// + private string m_message = null; + + /// + /// The exception recorded during the first error. + /// + private Exception m_exception = null; + + /// + /// The error code recorded during the first error. + /// + private ErrorCode m_errorCode = ErrorCode.GenericFailure; + + /// /// String to prefix each message with /// private readonly string m_prefix; #endregion Private Instance Fields } -} +} \ No newline at end of file