/// <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);
     }
 }
Example #3
0
 /// <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);
 }
Example #4
0
 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>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);
     }
 }
Example #7
0
 /// <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;
 }