exceptionMiddleware now capture statusCode != 200 response

This commit is contained in:
2021-05-29 11:33:30 +08:00
parent dfa9fbf909
commit 856c70d4ac
+5
View File
@@ -32,6 +32,10 @@ namespace SimApi.Middlewares
try try
{ {
await Next(context); await Next(context);
if (context.Response.StatusCode != 200)
{
throw new SimApiException(context.Response.StatusCode);
}
} }
catch (SimApiException ex) catch (SimApiException ex)
{ {
@@ -43,6 +47,7 @@ namespace SimApi.Middlewares
{ {
response.SetCodeMsg(ex.Code, ex.Message); response.SetCodeMsg(ex.Code, ex.Message);
} }
ErrorResponse(context, response); ErrorResponse(context, response);
} }
catch (Exception ex) catch (Exception ex)