Фикс в middleware исключений

1. Добавил 500 статус
2. Поменял порядок компонентов в middleware
This commit is contained in:
parent bd877d9f9a
commit eaff02294f
2 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,6 @@
using AsbCloudApp.Exceptions;
using Microsoft.AspNetCore.Http;
using System;
using System.IO;
using System.Threading.Tasks;
namespace AsbCloudWebApi.Middlewares
@ -36,12 +35,15 @@ namespace AsbCloudWebApi.Middlewares
context.Response.Clear();
context.Response.StatusCode = 403;
}
catch (TaskCanceledException ex)
catch (OperationCanceledException ex)
{
Console.WriteLine(ex.Message);
}
catch (Exception ex) // TODO: find explicit exception. Use Trace. Add body size to message.
{
context.Response.Clear();
context.Response.StatusCode = 500;
if (ex.Message.Contains("Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate."))
Console.WriteLine("Reading the request body timed out due to data arriving too slowly.");
else

View File

@ -141,8 +141,8 @@ namespace AsbCloudWebApi
app.UseAuthorization();
app.UseMiddleware<PermissionsMiddlware>(Configuration);
app.UseMiddleware<SimplifyExceptionsMiddleware>();
app.UseMiddleware<RequerstTrackerMiddleware>();
app.UseMiddleware<SimplifyExceptionsMiddleware>();
app.UseEndpoints(endpoints =>
{