} // HandleException private void HandleOwnedFormException(ExceptionEventData ex) { if (!HandleMyOwnExceptions) { var parent = ParentForm as CommonBaseForm; if (parent != null) { parent.GetExceptionHandler().Invoke(ex); } // if } // if ExceptionHandler(ex); } // HandleOwnedFormException
} // HandleException private void HandleOwnedFormException(CommonBaseForm form, ExceptionEventData ex) { if (!HandleOwnedFormsExceptions) { var parent = form.ParentForm as CommonBaseForm; if (parent != null) { parent.HandleOwnedFormException(this, ex); } // if } // if ExceptionHandler(form, ex); } // HandleOwnedFormException
} // HandleOwnedFormException /// <summary> /// Exception handler. /// By default displays an ExceptionMessageBox. Descendants are encouraged to provide their own implementation. /// </summary> /// <param name="ex">The data about the exception, including additional information for the user, such a caption or a text</param> /// <remarks>Descendants who override this method MUST NOT call base.ExceptionHandler. /// This method MUST NOT be called directly. To handle and exception, HandleException MUST be used instead. /// </remarks> protected virtual void ExceptionHandler(ExceptionEventData ex) { BasicGoogleTelemetry.SendExtendedExceptionHit(ex.Exception, true, ex.Message, this.GetType().Name); var box = new ExceptionMessageBox() { Caption = Properties.CommonForm.UncaughtExceptionCaption, Buttons = ExceptionMessageBoxButtons.OK, Symbol = ExceptionMessageBoxSymbol.Stop, }; if (ex.Message == null) { box.Text = ex.Exception.Message; box.Message = ex.Exception; } else { box.Text = ex.Message; box.InnerException = ex.Exception; } // if-else box.Show(ParentForm); } // ExceptionHandler
} // HandleMyOwnExceptions /// <summary> /// Provides an unified way of handling exceptions. /// </summary> /// <param name="ex">The data about the exception, including additional information for the user, such a caption or a text</param> /// <remarks>If a parent CommonForm exists, the exception will be passed along. /// If no parent is found, the virtual method ExceptionHandler will be called</remarks> protected void HandleException(ExceptionEventData ex) { HandleOwnedFormException(ex); } // HandleException
} // HandleException internal static void HandleException(Form form, ExceptionEventData ex) { MyApplication.HandleException(form, ex.Caption, ex.Message, ex.Exception); } // HandleException
protected override void ExceptionHandler(CommonBaseForm form, ExceptionEventData ex) { MyApplication.HandleException(form, ex); } // ExceptionHandler