public async Task InvokeAsync(HttpContext httpContext) { try { await _next(httpContext); } catch (Exception ex) { _logger.LogError($"There was an error while executing the request: {ex}"); if (_appOptions.IsInDevelopment()) { await HandleExceptionAsync(httpContext, ex, true); } await HandleExceptionAsync(httpContext, ex, _options.ReturnFullExceptionInProduction); } }