// Methods /// <summary> /// This is the Test Application's error handler. /// It handles reporting from SCOUT in addition to any error /// handling in the test application itself. </summary> /// <param name="sender"> This value will always be null for events that /// come from SCOUT because the source is a static library. </param> /// <param name="e"> You may use any custom event arguments you like. /// For simplicity, this test app uses Type 'Okuma.Scout.Error.Args' to make /// it easy to get exception and message information from SCOUT. </param> private void ReportAppError(object sender, Okuma.Scout.Error.Args e) { if (e.Severity == Okuma.Scout.Enums.MessageLevel.Exception) { AppendFlowLog(LoggingFlowDocument, e.Severity, e.Exception.ToString()); if (e.Exception.InnerException != null) { AppendFlowLog(LoggingFlowDocument, e.Severity, e.Exception.InnerException.ToString()); } // If you want the application to throw exceptions // for some reason, uncomment the line below. // throw e.Exception; } else { // This is not an exception, thus e.Exception // will be null and all of the relevant // debugging information will be held in e.Message AppendFlowLog(LoggingFlowDocument, e.Severity, e.Message.ToString()); } }
/// <summary> /// When handling the Reporter event, make sure to distinguish between /// exceptions and information. In the case of an exception, e.Message /// will be String.Empty, while in all other cases it will contain the /// error information and e.Exception will be null. </summary> /// <param name="sender">This value will always be null because the source is a /// static library.</param> /// <param name="e">Type 'Okuma.Scout.Error.Args', this value will /// contain exception and message information.</param> private void HandleScoutErrorInfo(object sender, Okuma.Scout.Error.Args e) { if (e.Severity == Okuma.Scout.Enums.MessageLevel.Exception) { this.PostError(e.Severity, e.Exception.ToString()); if (e.Exception.InnerException != null) { this.PostError(e.Severity, e.Exception.InnerException.ToString()); } // At this point Scout.dll has generated an exception and you have // the option of handling it gracefully, or throwing it. // to throw the exception uncomment the line below. // throw e.Exception; } else { // This is not an exception, thus e.Exception will be null // and all of the relevant debugging information will be held // in e.Message this.PostError(e.Severity, e.Message.ToString()); } }