From 7b94f9cc1ffcd6cb03adfd0bfb36c9b751bd5ccf Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Sun, 22 Dec 2024 05:51:11 +0300 Subject: [PATCH] refactor: for maintenance mode, return the standard error --- .../Common/Exceptions/ServerUnavailableException.cs | 8 ++++++++ .../Middleware/CustomExceptionHandlerMiddleware.cs | 8 ++++++++ .../Core/Middleware/MaintenanceModeMiddleware.cs | 12 +++++------- 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 Endpoint/Common/Exceptions/ServerUnavailableException.cs diff --git a/Endpoint/Common/Exceptions/ServerUnavailableException.cs b/Endpoint/Common/Exceptions/ServerUnavailableException.cs new file mode 100644 index 0000000..7e58d61 --- /dev/null +++ b/Endpoint/Common/Exceptions/ServerUnavailableException.cs @@ -0,0 +1,8 @@ +using System; + +namespace Mirea.Api.Endpoint.Common.Exceptions; + +public class ServerUnavailableException(string message, bool addRetryAfter) : Exception(message) +{ + public bool AddRetryAfter { get; } = addRetryAfter; +} \ No newline at end of file diff --git a/Endpoint/Configuration/Core/Middleware/CustomExceptionHandlerMiddleware.cs b/Endpoint/Configuration/Core/Middleware/CustomExceptionHandlerMiddleware.cs index 3c65dd8..23c848b 100644 --- a/Endpoint/Configuration/Core/Middleware/CustomExceptionHandlerMiddleware.cs +++ b/Endpoint/Configuration/Core/Middleware/CustomExceptionHandlerMiddleware.cs @@ -71,6 +71,14 @@ public class CustomExceptionHandlerMiddleware(RequestDelegate next, ILogger