-
Notifications
You must be signed in to change notification settings - Fork 256
Open
Description
Feature request checklist
- There are no issues that match the desired change
- The change is large enough it can't be addressed with a simple Pull Request
- If this is a bug, please file a Bug Report.
Change
When ContextEval aborts evaluation because the context is canceled, it returns an error with "operation interrupted" without wrapping the ctx.Err() or (even better) the context.Cause(ctx). The caller than has to figure out via string comparisons whether the actual root cause was context cancellation and add back the cause.
Example
result, details, err := c.Program.ContextEval(ctx, variables)
if err != nil {
// Informative error wrapping the cancellation cause returned here.
return false, details, err
}Alternatives considered
result, details, err := c.Program.ContextEval(ctx, variables)
if err != nil {
// CEL does not wrap the context error. We have to deduce why it failed.
if strings.Contains(err.Error(), "operation interrupted") && ctx.Err() != nil {
return false, details, fmt.Errorf("%w: %w", err, context.Cause(ctx))
}
return false, details, err
}Metadata
Metadata
Assignees
Labels
No labels