Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.94 KB | None | 0 0
  1. namespace Infrastructure.Web.Api.Mvc
  2.  
  3. module ExceptionFilters =
  4.     open Microsoft.AspNetCore.Mvc.Filters
  5.     open Microsoft.Extensions.Logging
  6.     open Infrastructure.Web.Api.Localization
  7.     open System
  8.     open Microsoft.AspNetCore.Mvc
  9.  
  10.     type OperationCanceledExceptionFilter =
  11.         inherit ExceptionFilterAttribute
  12.         val private internalLogger : ILogger<OperationCanceledExceptionFilter>
  13.         new (logger : ILogger<OperationCanceledExceptionFilter>) =
  14.             {
  15.                 internalLogger = logger
  16.             }
  17.        
  18.         override __.OnException (context : ExceptionContext) =
  19.             match context.Exception with
  20.             | :? OperationCanceledException ->
  21.                 internalLogger.LogInformation(Resources.RequestWasCancelled)
  22.                 context.ExceptionHandled <- true
  23.                 context.Result <- StatusCodeResult(499)
  24.                 ()
  25.             | _ -> ()
  26.             ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement