public void OnErrorModuleFiltering(object sender, ExceptionFilterEventArgs args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } if (args.Exception == null) { throw new ArgumentException(null, nameof(args)); } try { if (Assertion.Test(new AssertionHelperContext(sender, args.Exception, args.Context))) { if (Notifiers.Any()) { args.DismissForNotifiers(Notifiers); } args.Dismiss(); } } catch (Exception e) { Trace.WriteLine(e); throw; } }
/// <summary> /// Raises the <see cref="Filtering"/> event. /// </summary> protected virtual void OnFiltering(ExceptionFilterEventArgs args) { Filtering?.Invoke(this, args); }
protected void LogException(Exception e, HttpContext context) { if (e == null) { throw new ArgumentNullException(nameof(e)); } // // Fire an event to check if listeners want to filter out // logging of the uncaught exception. // ErrorLogEntry entry = null; try { var args = new ExceptionFilterEventArgs(e, context); if (_filters.Any()) { OnFiltering(args); if (args.Dismissed && !args.DismissedNotifiers.Any()) { return; } } // // Log away... // var error = new Error(e, context); var log = GetErrorLog(context); error.ApplicationName = log.ApplicationName; var id = log.Log(error); entry = new ErrorLogEntry(log, id, error); //Send notification foreach (var notifier in _notifiers) { if (!args.DismissedNotifiers.Any(i => i.Equals(notifier.Name, StringComparison.InvariantCultureIgnoreCase))) { notifier.Notify(error); } } } catch (Exception localException) { // // IMPORTANT! We swallow any exception raised during the // logging and send them out to the trace . The idea // here is that logging of exceptions by itself should not // be critical to the overall operation of the application. // The bad thing is that we catch ANY kind of exception, // even system ones and potentially let them slip by. // _logger.LogError("Elmah local exception", localException); } if (entry != null) { OnLogged(new ErrorLoggedEventArgs(entry)); } }