Error codes for each error variant in Core/Validator #184
Labels
backlog
We hope to work on this in the future
feature-request
Request for a new feature
work-in-progress
Implementation work in progress
Category
User level API changes
Describe the feature you'd like to request
Every error variant (eg
PolicySetError::ExpectedStatic
) should have an assigned error code, which shows up in both the error message and the rustdoc for that variant. We should systematically assign these error codes, maybe including letters and/or numbers.Describe the solution you'd like
I'm happy to take arguments about what the error codes should look like, but here's an initial proposal:
V
for validation-related errors,A
for errors thrown byis_authorized()
, etc. (Not sure exactly how many categories we should have.)EvaluationError
miette
provides nice way to expose these by addingcode(...)
to the#[diagnostic(...)]
attribute.miette
recommends error codes of a form likecedar_policy_core::parse::parse_err
. But there's nothing saying we have to obey that. We could also combine this with the above, e.g.,cedar::A100
orcedar_policy::A100
.This should not be a breaking change, it should only be a change to error messages and docstrings.
Describe alternatives you've considered
We could instead just have textual error codes that are basically the error struct and variant name. This gives us a little less flexibility to refactor our error structs in the future. I'm not sure whether our users would prefer to look up (or Google) a code like "A100" or a textual code like "EvaluationError::IntegerOverflow".
Additional context
No response
Is this something that you'd be interested in working on?
The text was updated successfully, but these errors were encountered: