public static void Present(this UserPresentableException e, object uiContext = null) { Log.Error(TAG, $"{e.Message} ({e.Details})", e.InnerException ?? e); MainThread.Ensure(); var window = new MetroDialogWindow { Title = e.Message, Message = e.Details, AffirmativeButtonText = Catalog.GetString("OK") }; var ownerWindow = uiContext as Window; if (ownerWindow == null) { window.Owner = ownerWindow; window.Width = 400; window.WindowStartupLocation = WindowStartupLocation.CenterScreen; } else { window.Width = ownerWindow.Width; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; } window.ShowDialog(); }
public static void Present(this UserPresentableException e, object uiContext = null) { Log.Error(TAG, $"{e.Message} ({e.Details})", e.InnerException ?? e); MainThread.Ensure(); uiContext = uiContext ?? e.UIContext; var window = (uiContext as NSViewController)?.View?.Window ?? (uiContext as NSView)?.Window ?? (uiContext as NSWindowController)?.Window ?? uiContext as NSWindow; var alert = new NSAlert { AlertStyle = NSAlertStyle.Critical, MessageText = e.Message, InformativeText = e.Details }; if (window == null) { alert.RunModal(); } else { alert.BeginSheet(window, resp => { }); } }
public Error(UserPresentableException upe) : base("error.upe") { CallerName = upe.CallerMemberName; CallerFile = upe.CallerFilePath; CallerLine = upe.CallerLineNumber; }
public static Message CreateErrorAlert(UserPresentableException exception) => Create( MessageKind.Alert, MessageSeverity.Error, exception.Message, exception.Details);
protected override void PresentError(UserPresentableException upe) => upe.Present(viewController);