Add handling for update and delete exceptions

Enhanced `ExceptionHandlingMiddleware` to handle
`UpdateObjectFailedException` and `DeleteObjectFailedException`.
Logs exception details, including serialized procedure data,
and sets HTTP status to `500 Internal Server Error`.
Improves error differentiation and response for specific failure cases.
This commit is contained in:
Developer 02
2026-01-16 01:10:57 +01:00
parent a5160b35dd
commit cbd86de3e8

View File

@@ -123,6 +123,40 @@ public class ExceptionHandlingMiddleware
};
break;
case UpdateObjectFailedException updateFailedEx:
logger.LogError(
updateFailedEx,
"Update operation failed during request processing. {procedure}",
JsonSerializer.Serialize(
updateFailedEx.Procedure,
options: new() { WriteIndented = true }
));
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
details = new()
{
Title = "Update Operation Failed",
Detail = updateFailedEx.Message
};
break;
case DeleteObjectFailedException deleteFailedEx:
logger.LogError(
deleteFailedEx,
"Delete operation failed during request processing. {procedure}",
JsonSerializer.Serialize(
deleteFailedEx.Procedure,
options: new() { WriteIndented = true }
));
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
details = new()
{
Title = "Delete Operation Failed",
Detail = deleteFailedEx.Message
};
break;
default:
logger.LogError(exception, "Unhandled exception occurred.");
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;