/// <summary> /// Shows the message -- includes root cause information that can optionally /// be made available for logging and/or for developers or motivated/curious /// end users. /// </summary> public virtual void ShowMessage(IWin32Window owner, Exception rootCause, params object[] args) { string dialogTitle = Title; string dialogMessage = FormatText(args); bool isUnexpected = true; //check for special error message type ExceptionMessage dynamicMessage; if (DynamicExceptionMessageRegistry.Instance.GetMessage(out dynamicMessage, rootCause)) { if (dynamicMessage == null) { return; } else { dialogTitle = dynamicMessage.GetTitle(Title); dialogMessage = dynamicMessage.GetMessage(args); isUnexpected = dynamicMessage.Unexpected; } } Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0}\r\nException Details:\r\n{1}\r\n{2}", title, dialogMessage, rootCause.ToString()), ErrText.FailText); try { using (Form errorDialog = new UnexpectedErrorDialog(dialogTitle, dialogMessage, rootCause)) { if (owner != null) { errorDialog.ShowDialog(owner); } else { errorDialog.ShowDialog(); } } } catch (Exception ex) { Trace.Fail("Failure while attempting to show unexpected error", ex.Message); } }
/// <summary> /// Shows the message -- includes root cause information that can optionally /// be made available for logging and/or for developers or motivated/curious /// end users. /// </summary> public virtual void ShowMessage(IWin32Window owner, Exception rootCause, params object[] args) { string dialogTitle = Title; string dialogMessage = FormatText(args); bool isUnexpected = true; //check for special error message type ExceptionMessage dynamicMessage; if (DynamicExceptionMessageRegistry.Instance.GetMessage(out dynamicMessage, rootCause)) { if (dynamicMessage == null) return; else { dialogTitle = dynamicMessage.GetTitle(Title); dialogMessage = dynamicMessage.GetMessage(args); isUnexpected = dynamicMessage.Unexpected; } } Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0}\r\nException Details:\r\n{1}\r\n{2}", title, dialogMessage, rootCause.ToString()), ErrText.FailText); try { using (Form errorDialog = new UnexpectedErrorDialog(dialogTitle, dialogMessage, rootCause)) { if (owner != null) errorDialog.ShowDialog(owner); else errorDialog.ShowDialog(); } } catch (Exception ex) { Trace.Fail("Failure while attempting to show unexpected error", ex.Message); } }