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

Give more context in Violation struct #102

Open
backesj opened this issue Jul 28, 2022 · 2 comments
Open

Give more context in Violation struct #102

backesj opened this issue Jul 28, 2022 · 2 comments

Comments

@backesj
Copy link

backesj commented Jul 28, 2022

Currently the violation struct looks like this:

pub struct Violation {
    constraint: String,  // represents the constraint that created this violation
    code: ViolationCode, // represents an error code that indicates the type of the violation
    message: String,     // represents the detailed error message for this violation
    violations: Vec<Violation>,
}

It would be great if it also contained line numbers and a snippet of the content of the line that caused the error. Right now it's very difficult to figure out what caused the violation with the current context.

@desaikd
Copy link
Contributor

desaikd commented Jul 29, 2022

Thanks for reaching out about this @backesj!
As per the current implementation, ion-schema-rust doesn't have Display implementation for Violation. I am working on a Display for Violation which could help make it more readable. It might not include line numbers at the moment but maybe a nested Struct with all the violations found during the validation process along with the type name that caused the violation would helpful enough to point at the root cause.

I have created this issue for reference: #105

Let me know if there was some specific use case you were looking for to add enough context to violation Display implementation.

@backesj
Copy link
Author

backesj commented Aug 2, 2022

Thanks for the response! Mostly I think it would be valuable to provide line numbers and the content of the line so that users can more quickly identify the source of validation errors. This isn't in the formatted display currently, and it can be challenging to quickly locate the problem for violations that occur deep in an ION structure.

@popematt popematt changed the title Give move context in Violation struct Give more context in Violation struct Oct 18, 2022
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

No branches or pull requests

2 participants