refactor: for maintenance mode, return the standard error

This commit is contained in:
2024-12-22 05:51:11 +03:00
parent 7bafbb95c4
commit 7b94f9cc1f
3 changed files with 21 additions and 7 deletions

View File

@ -71,6 +71,14 @@ public class CustomExceptionHandlerMiddleware(RequestDelegate next, ILogger<Cust
problemDetails.Type = "https://tools.ietf.org/html/rfc9110#section-15.5.2";
problemDetails.Title = "Unauthorized access.";
break;
case ServerUnavailableException unavailableException:
problemDetails.Status = StatusCodes.Status503ServiceUnavailable;
problemDetails.Type = "https://datatracker.ietf.org/doc/html/rfc9110#section-15.6.4";
problemDetails.Title = "Server unavailable.";
problemDetails.Detail = unavailableException.Message;
if (unavailableException.AddRetryAfter)
context.Response.Headers.RetryAfter = "600";
break;
}
if (problemDetails.Status == StatusCodes.Status500InternalServerError)