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

Add more fields to IonSchemaError to be used for PartialEq #141

Open
desaikd opened this issue Jan 23, 2023 · 1 comment
Open

Add more fields to IonSchemaError to be used for PartialEq #141

desaikd opened this issue Jan 23, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@desaikd
Copy link
Contributor

desaikd commented Jan 23, 2023

I'm a little uneasy about having the equality function test only for description string equality, which can be pretty fragile. Developers are likely to write unit tests against a given error string, which means we can't change that error string down the road without also breaking their tests.

We do description string comparisons like this in ion-rust's IonError type, but the description messages are intentionally terse and do not include lots of contextual information like position. Even there I don't love it.

I suppose ideally we'd have fields besides the description that characterized the nature of the failure. For example, a schema_name field in each UnresolvableSchemaError, or an enum of reasons that an InvalidSchemaError occurred. Well-defined, tightly-scoped fields that we're comfortable committing to using in our PartialEq impl.

This doesn't need to block this PR, but we should think it through before 1.0.

Originally posted by @zslayton in #139 (comment)

@dlurton
Copy link

dlurton commented Feb 10, 2023

You can probably just make an impl of PartialEq that ignores the description, and possibly other fields in that case. (Although I would definitely include the position of the error within the document being validated (not within the ISL).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants