diff --git a/src/Core/API/API.Core/GlobalException.cs b/src/Core/API/API.Core/GlobalException.cs index 72f7821..6115f64 100644 --- a/src/Core/API/API.Core/GlobalException.cs +++ b/src/Core/API/API.Core/GlobalException.cs @@ -3,6 +3,7 @@ using API.Core.Contracts.Common; using Domain.Exceptions; using FluentValidation; +using Microsoft.Data.SqlClient; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; @@ -71,6 +72,16 @@ public class GlobalExceptionFilter(ILogger logger) context.ExceptionHandled = true; break; + case SqlException ex: + context.Result = new ObjectResult( + new ResponseBody { Message = "A database error occurred." } + ) + { + StatusCode = 503, + }; + context.ExceptionHandled = true; + break; + case Domain.Exceptions.ValidationException ex: context.Result = new ObjectResult( new ResponseBody { Message = ex.Message }