public async Task InvokeAsync(IHttpOperationContext context) { try { await _next(context).ConfigureAwait(false); } catch (HttpRequestException ex) { context.Result.ClearAll(); context.Result.AddError( ErrorBuilder.FromException(ex) .SetCode(ErrorCodes.Http) .Build()); } catch (Exception ex) { context.Result.ClearAll(); context.Result.AddError( ErrorBuilder.FromException(ex) .SetCode(ErrorCodes.Unexpected) .Build()); } }