public override void ShowException(Exception ex, string message) { SD.Log.Error(message, ex); SD.Log.Warn("Stack trace of last exception log:\n" + Environment.StackTrace); if (ex != null) { ExceptionBox.ShowErrorBox(ex, message); } else { ShowError(message); } }
static void ShowErrorBox(Exception exception, string message, bool mustTerminate) { // ignore reentrant calls (e.g. when there's an exception in OnRender) if (showingBox) { return; } showingBox = true; try { if (exception != null) { try { SD.AnalyticsMonitor.TrackException(exception); } catch (Exception ex) { LoggingService.Warn("Error tracking exception", ex); } } using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { if (SD.MainThread.InvokeRequired) { box.ShowDialog(); } else { box.ShowDialog(SD.WinForms.MainWin32Window); } } } catch (Exception ex) { LoggingService.Warn("Error showing ExceptionBox", ex); MessageBox.Show(exception != null ? exception.ToString() : "Error", message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } finally { showingBox = false; } }