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:
parent
97c57d4fb1
commit
cc787f445a
@ -15,8 +15,10 @@ public class BodyQueryBehavior<TRecAction>(IRecDbContext dbContext) : IPipelineB
|
|||||||
|
|
||||||
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).FirstOrDefaultAsync(cancel);
|
var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).FirstOrDefaultAsync(cancel);
|
||||||
|
|
||||||
if (result is null || result.RawBody is null)
|
if (result?.RawBody is null)
|
||||||
throw new InvalidOperationException("Body query did not return a result or returned a null REQUEST_BODY.");
|
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;
|
action.Body = result.RawBody;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user