feat: return security exception

This commit is contained in:
Polianin Nikita 2024-10-31 04:07:35 +03:00
parent 3279ef594b
commit 0f47a98ad9

View File

@ -5,6 +5,7 @@ using Mirea.Api.DataAccess.Application.Common.Exceptions;
using Mirea.Api.Dto.Responses; using Mirea.Api.Dto.Responses;
using Mirea.Api.Endpoint.Common.Exceptions; using Mirea.Api.Endpoint.Common.Exceptions;
using System; using System;
using System.Security;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -44,6 +45,9 @@ public class CustomExceptionHandlerMiddleware(RequestDelegate next, ILogger<Cust
case ControllerArgumentException: case ControllerArgumentException:
code = StatusCodes.Status400BadRequest; code = StatusCodes.Status400BadRequest;
break; break;
case SecurityException:
code = StatusCodes.Status401Unauthorized;
break;
} }
context.Response.ContentType = "application/json"; context.Response.ContentType = "application/json";