forked from ddrilling/AsbCloudServer
Фикс в middleware исключений
1. Добавил 500 статус 2. Поменял порядок компонентов в middleware
This commit is contained in:
parent
bd877d9f9a
commit
eaff02294f
@ -1,7 +1,6 @@
|
|||||||
using AsbCloudApp.Exceptions;
|
using AsbCloudApp.Exceptions;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Middlewares
|
namespace AsbCloudWebApi.Middlewares
|
||||||
@ -36,12 +35,15 @@ namespace AsbCloudWebApi.Middlewares
|
|||||||
context.Response.Clear();
|
context.Response.Clear();
|
||||||
context.Response.StatusCode = 403;
|
context.Response.StatusCode = 403;
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException ex)
|
catch (OperationCanceledException ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
catch (Exception ex) // TODO: find explicit exception. Use Trace. Add body size to 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."))
|
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.");
|
Console.WriteLine("Reading the request body timed out due to data arriving too slowly.");
|
||||||
else
|
else
|
||||||
|
@ -141,8 +141,8 @@ namespace AsbCloudWebApi
|
|||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.UseMiddleware<PermissionsMiddlware>(Configuration);
|
app.UseMiddleware<PermissionsMiddlware>(Configuration);
|
||||||
app.UseMiddleware<SimplifyExceptionsMiddleware>();
|
|
||||||
app.UseMiddleware<RequerstTrackerMiddleware>();
|
app.UseMiddleware<RequerstTrackerMiddleware>();
|
||||||
|
app.UseMiddleware<SimplifyExceptionsMiddleware>();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user