/// <summary>Removes the specified handler from the list of exception handlers.</summary> public void RemoveExceptionHandler(IHttpExceptionHandler handler) { lock (exceptionHandlersLock) { exceptionHandlers.Remove(handler); } }
/// <summary>Adds the specified handler to the list of exception handlers.</summary> public void AddExceptionHandler(IHttpExceptionHandler handler) { lock (exceptionHandlersLock) { exceptionHandlers.Add(handler); } }
/// <summary> /// Add an exception handler for this request only. /// </summary> /// <param name="handler">The exception handler. Must not be <c>null</c>.</param> public void AddExceptionHandler(IHttpExceptionHandler handler) { handler.ThrowIfNull(nameof(handler)); if (_exceptionHandlers == null) { _exceptionHandlers = new List <IHttpExceptionHandler>(); } _exceptionHandlers.Add(handler); }
public async Task InvokeAsync(HttpContext context) { try { await _next(context); } catch (Exception exception) { IHttpExceptionHandler handler = _handlers.Where(handler => handler.CanHandle(exception)).FirstOrDefault(); if (handler is null || context.Response.HasStarted) { throw; }
/// <summary> /// Initializes a new instance of the <see cref="AnalyticsProvider" /> class. /// </summary> /// <param name="exceptionHandler">The exception handler.</param> /// <param name="unsuccessfulResponseHandler">The unsuccessful response handler.</param> public AnalyticsProvider(IHttpExceptionHandler exceptionHandler, IHttpUnsuccessfulResponseHandler unsuccessfulResponseHandler) { this.exceptionHandler = exceptionHandler; this.unsuccessfulResponseHandler = unsuccessfulResponseHandler; }