Merge pull request 'Фикс в middleware исключений' (#64) from feature/fix_exception into dev

Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/64
This commit is contained in:
Никита Фролов 2023-06-30 13:25:18 +05:00
commit 56922410ab

View File

@ -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