Improve null-checking and error handling in Handle

Simplified null-checks in the `Handle` method of the
`BodyQueryBehavior` class using the null-conditional operator.
Enhanced the exception message to include `ProfileId` and
`ActionId` for better debugging context when `result?.RawBody`
is null.
This commit is contained in:
Developer 02 2025-11-28 23:37:09 +01:00
parent 97c57d4fb1
commit cc787f445a

View File

@ -15,8 +15,10 @@ public class BodyQueryBehavior<TRecAction>(IRecDbContext dbContext) : IPipelineB
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).FirstOrDefaultAsync(cancel);
if (result is null || result.RawBody is null)
throw new InvalidOperationException("Body query did not return a result or returned a null REQUEST_BODY.");
if (result?.RawBody is null)
throw new InvalidOperationException(
$"Body query did not return a result or returned a null REQUEST_BODY. " +
$"ProfileId: {action.ProfileId}, ActionId: {action.ActionId}.");
action.Body = result.RawBody;