diff --git a/src/ReC.API/Middleware/ExceptionHandlingMiddleware.cs b/src/ReC.API/Middleware/ExceptionHandlingMiddleware.cs index dc02a81..0486ea6 100644 --- a/src/ReC.API/Middleware/ExceptionHandlingMiddleware.cs +++ b/src/ReC.API/Middleware/ExceptionHandlingMiddleware.cs @@ -1,4 +1,5 @@ using DigitalData.Core.Exceptions; +using ReC.Application.Common.Exceptions; using System.Net; using System.Text.Json; @@ -69,6 +70,11 @@ public class ExceptionHandlingMiddleware message = notFoundEx.Message; break; + case DataIntegrityException dataIntegrityEx: + context.Response.StatusCode = (int)HttpStatusCode.Conflict; + message = dataIntegrityEx.Message; + break; + default: logger.LogError(exception, "Unhandled exception occurred."); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;