cel-go
cel-go copied to clipboard
Unify error codes / messages
Issue Filing Checklist
- [X] There are no issues that match the desired change
- [X] The change is large enough it can't be addressed with a simple Pull Request
Change
Error messages are formatted strings which are not uniform. While this was okay for development, the errors should be consolidated into error codes with a set of associated details. Further, when multiple errors are encountered they should be aggregated together rather than simply picking the first one.
Proposed error codes:
| Code | Details | Description |
|---|---|---|
ATTRIBUTE_NOT_FOUND |
type, attribute | Map or object access using an unknown attribute. |
DIVIDE_BY_ZERO |
n/a | Division by zero, also reported for modulus operations. |
DUPLICATE_ATTRIBUTE |
attribute name | Map or object construction supplies same key value more than once. |
IDENTIFIER_NOT_FOUND |
identifier name | Variable or function name could not be found. |
INVALID_ARGUMENT |
argument value | Invalid argument supplied to a function. |
OVERLOAD_NOT_FOUND |
function signature | Function defined, but no matching overload found. |
TYPE_NOT_FOUND |
type name | Type definition could not be found. |
Example
return types.NewError(errors.ATTRIBUTE_NOT_FOUND, value.Type(), field)
Hi @TristonianJones, any updates on this? We would find it incredibly useful to be able to provide better errors messages when CEL evaluation fails.
Happy to help if need be.