Browse Source

[EC-619] Exceeding seat limit results in vague "Unhandled server error" message (#2558)

* [EC-619] Added 'AggregateException' type to ExceptionHandlerFilter to return error messages in response

* [EC-619] Updated ExceptionHandlerFilterAttribute to return multiple errors using ErrorResponseModel internal property
pull/2579/head
Rui Tomé 3 years ago committed by GitHub
parent
commit
22201bf30a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/Api/Utilities/ExceptionHandlerFilterAttribute.cs

13
src/Api/Utilities/ExceptionHandlerFilterAttribute.cs

@ -92,6 +92,19 @@ public class ExceptionHandlerFilterAttribute : ExceptionFilterAttribute @@ -92,6 +92,19 @@ public class ExceptionHandlerFilterAttribute : ExceptionFilterAttribute
errorMessage = "Unauthorized.";
context.HttpContext.Response.StatusCode = 401;
}
else if (exception is AggregateException aggregateException)
{
context.HttpContext.Response.StatusCode = 400;
var errorValues = aggregateException.InnerExceptions.Select(ex => ex.Message);
if (_publicApi)
{
publicErrorModel = new ErrorResponseModel(errorMessage, errorValues);
}
else
{
internalErrorModel = new InternalApi.ErrorResponseModel(errorMessage, errorValues);
}
}
else
{
var logger = context.HttpContext.RequestServices.GetRequiredService<ILogger<ExceptionHandlerFilterAttribute>>();

Loading…
Cancel
Save