Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Infrastructure.Web.Api.Mvc
- open Microsoft.AspNetCore.Mvc.Filters
- open Microsoft.Extensions.Logging
- open Infrastructure.Web.Api.Localization
- open System
- open Microsoft.AspNetCore.Mvc
- type OperationCanceledExceptionFilter=
- inherit ExceptionFilterAttribute
- val private internalLogger : ILogger<OperationCanceledExceptionFilter>
- new (logger : ILogger<OperationCanceledExceptionFilter>) =
- {
- inherit ExceptionFilterAttribute()
- if isNull(logger) then nullArg("logger")
- internalLogger = logger
- }
- override this.OnException (context : ExceptionContext) =
- match context.Exception with
- | :? OperationCanceledException ->
- this.internalLogger.LogInformation(Resources.RequestWasCancelled)
- context.ExceptionHandled <- true
- context.Result <- StatusCodeResult(499)
- ()
- | _ -> ()
- ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement