/// <summary> /// Processes unhandled exceptions. /// </summary> /// <param name="exception">The unhandled exception to process.</param> public void Handle( Exception exception ) { if( exception.NullReference() ) return; AppCore.Log.Error("Unhandled exception caught!", exception); }
/// <summary> /// Processes unhandled exceptions. /// </summary> /// <param name="exception">The unhandled exception to process.</param> public void Handle( Exception exception ) { if( exception.NullReference() ) return; // NOTE: SafeString should be fool-proof, but in case we encounter a bug in it // at the worst moment, let's report it as well string str; try { str = "Unhandled exception caught:" + Environment.NewLine + SafeString.DebugPrint(exception); } catch( Exception safeStringException ) { var sb = new StringBuilder(); sb.AppendLine("Unhandled exception caught:"); sb.AppendLine(exception.ToString()); sb.AppendLine(); sb.AppendLine("Error encountered while logging the exception:"); sb.AppendLine(safeStringException.ToString()); str = sb.ToString(); } #if !SILVERLIGHT // Unlike Debug, Trace remains in Release builds Trace.WriteLine(str); Trace.Flush(); #else Debug.WriteLine(str); #endif }
private void Log( LogLevel level, string message, Exception ex = null, [CallerFilePath] string filePath = "", [CallerMemberName] string memberName = "", [CallerLineNumber] int lineNumber = 0 ) { var info = ex.NullReference() ? null : ExceptionInfo.From(ex); var entry = new LogEntry(level, message, info, filePath, memberName, lineNumber); this.Log(entry); }
/// <summary> /// Processes unhandled exceptions. /// </summary> /// <param name="exception">The unhandled exception to process.</param> public void Handle( Exception exception ) { if( exception.NullReference() ) return; UI.Invoke(() => { MessageBox.Show( SafeString.DebugFormat("An unhandled exception of type '{0}' was caught and logged!", exception.GetType()), "Unhandled exception!", MessageBoxButton.OK, MessageBoxImage.Error); }); }