Handle RecActionException in middleware with 422 response

Added specific handling for RecActionException in the exception middleware. Now logs a warning with ActionId and ProfileId, returns a 422 Unprocessable Entity status, and provides detailed error information in the response.
This commit is contained in:
2026-03-25 10:26:24 +01:00
parent 08c0d29d84
commit 26b7a82451

View File

@@ -164,6 +164,22 @@ public class ExceptionHandlingMiddleware
}; };
break; break;
case RecActionException recActionEx:
logger.LogWarning(
recActionEx,
"Rec action failed. ActionId: {ActionId}, ProfileId: {ProfileId}",
recActionEx.ActionId,
recActionEx.ProfileId);
context.Response.StatusCode = (int)HttpStatusCode.UnprocessableEntity;
details = new()
{
Title = "Rec Action Failed",
Detail = recActionEx.InnerException?.Message
?? "An error occurred while executing the rec action. Check the logs for more details."
};
break;
default: default:
logger.LogError(exception, "Unhandled exception occurred."); logger.LogError(exception, "Unhandled exception occurred.");
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;