Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return only the raw evaluation error message without prefix #1726

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Nov 23, 2023

At the moment we store any evaluation error as string(err) which is
great for its simplicity and allows us to unwrap the error and test it
with errors.Is or errors.As, but the string representation also
includes the string representation of the error itself.

In order to both support unwrapping but also be able to extract only the
raw message from the evaluator, let's add a EvaluationError structure
that implements the error interface so it can be tested for with As,
unwraps into base which is ErrEvaluationFailed through the usual
NewErrEvaluationFailed.

The user-visible result is that the errors are no longer stored with the
evaluation failure prefix, but raw, which will be useful for storing
JSON in the result.

At the moment we store any evaluation error as `string(err)` which is
great for its simplicity and allows us to unwrap the error and test it
with `errors.Is` or `errors.As`, but the string representation also
includes the string representation of the error itself.

In order to both support unwrapping but also be able to extract only the
raw message from the evaluator, let's add a `EvaluationError` structure
that implements the error interface so it can be tested for with `As`,
unwraps into base which is `ErrEvaluationFailed` through the usual
`NewErrEvaluationFailed`.

The user-visible result is that the errors are no longer stored with the
`evaluation failure` prefix, but raw, which will be useful for storing
JSON in the result.
@jhrozek jhrozek merged commit 3c679b6 into mindersec:main Nov 24, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants