} // proc ShowException /// <summary>Display the exception dialog.</summary> /// <param name="dialogOwner"></param> /// <param name="flags"></param> /// <param name="exception"></param> /// <param name="alternativeMessage"></param> /// <returns></returns> public bool ShowExceptionDialog(Window dialogOwner, ExceptionShowFlags flags, Exception exception, string alternativeMessage) { switch (exception) { case PpsEnvironmentOnlineFailedException ex: return(MsgBox(ex.Message, MessageBoxButton.OK, MessageBoxImage.Information) != MessageBoxResult.OK); case ILuaUserRuntimeException urex: return(MsgBox(urex.Message, MessageBoxButton.OK, MessageBoxImage.Information) != MessageBoxResult.OK); default: var shutDown = (flags & ExceptionShowFlags.Shutown) != 0; if (!shutDown && alternativeMessage != null) { MsgBox(alternativeMessage, MessageBoxButton.OK, MessageBoxImage.Information); return(false); } else { MsgBox(alternativeMessage ?? exception.Message, MessageBoxButton.OK, MessageBoxImage.Error); return(false); //var dialog = new PpsMessageDialog //{ // MessageType = shutDown ? PpsTraceItemType.Fail : PpsTraceItemType.Exception, // MessageText = alternativeMessage ?? exception.Message, // SkipVisible = !shutDown, // Owner = dialogOwner //}; //return dialog.ShowDialog() ?? false; // show the dialog } } } // func ShowExceptionDialog
/// <summary></summary> /// <param name="flags"></param> /// <param name="exception"></param> /// <param name="alternativeMessage"></param> public override void ShowException(ExceptionShowFlags flags, Exception exception, string alternativeMessage = null) { Log.Append(PpsLogType.Exception, exception, alternativeMessage); if ((flags & ExceptionShowFlags.Background) != ExceptionShowFlags.Background) { // show message simple MsgBox(alternativeMessage ?? exception.UnpackException().ToString(), MessageBoxButton.OK, MessageBoxImage.Error); // shutdown application if ((flags & ExceptionShowFlags.Shutown) == ExceptionShowFlags.Shutown) { Application.Current.Shutdown(1); } } } // proc ShowException
} // proc TransformPoint #endregion #region -- Dialogs ------------------------------------------------------------ public static void ShowException(this IWin32Window owner, ExceptionShowFlags flags, Exception exception, string alternativeMessage = null) { var unpackedException = exception.UnpackException(); if ((flags & ExceptionShowFlags.Warning) != 0) { MessageBox.Show(owner, alternativeMessage ?? unpackedException.Message, "Hinweis", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (unpackedException is ExcelException excelException) { MessageBox.Show(owner, alternativeMessage ?? excelException.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { using (var exceptionDialog = new ExceptionDialog()) { exceptionDialog.SetData(alternativeMessage, unpackedException, false); exceptionDialog.ShowDialog(owner); } } } // proc ShowException
/// <summary>Display the exception dialog.</summary> /// <param name="flags"></param> /// <param name="exception"></param> /// <param name="alternativeMessage"></param> public override void ShowException(ExceptionShowFlags flags, Exception exception, string alternativeMessage = null) { var exceptionToShow = exception.UnpackException(); // always add the exception to the list Log.Append(PpsLogType.Exception, exception, alternativeMessage ?? exceptionToShow.Message); // show the exception if it is not marked as background if ((flags & ExceptionShowFlags.Background) != ExceptionShowFlags.Background && Application.Current != null) { var dialogOwner = Application.Current.Windows.OfType <Window>().FirstOrDefault(c => c.IsActive); if (ShowExceptionDialog(dialogOwner, flags, exceptionToShow, alternativeMessage)) // should follow a detailed dialog { ShowTraceAsync(dialogOwner).AwaitTask(); } if ((flags & ExceptionShowFlags.Shutown) != 0) // close application { Application.Current.Shutdown(1); } } } // proc ShowException
/// <summary>Notifies a exception in the UI context.</summary> /// <param name="flags"></param> /// <param name="exception"></param> /// <param name="alternativeMessage"></param> /// <returns></returns> public virtual Task ShowExceptionAsync(ExceptionShowFlags flags, Exception exception, string alternativeMessage = null) => InvokeAsync(() => ShowException(flags, exception, alternativeMessage));
/// <summary>Notifies a exception in the UI context.</summary> /// <param name="flags"></param> /// <param name="exception"></param> /// <param name="alternativeMessage"></param> public abstract void ShowException(ExceptionShowFlags flags, Exception exception, string alternativeMessage = null);
public override void ShowException(ExceptionShowFlags flags, Exception exception, string alternativeMessage = null) => formsApplication.ShowException(flags, exception, alternativeMessage);