public ErrorHandlerMiddleware(RequestDelegate next, IJson json,
                               ILogger <ErrorHandlerMiddleware> logger,
                               ApiExceptionOptions options)
 {
     this.next    = next;
     this.json    = json;
     this.logger  = logger;
     this.options = options;
 }
        public static IApplicationBuilder UseApiExceptionHandler(this IApplicationBuilder builder,
                                                                 Action <ApiExceptionOptions> configureOptions)
        {
            var options = new ApiExceptionOptions();

            configureOptions(options);

            return(builder.UseMiddleware <ErrorHandlerMiddleware>(options));
        }