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

Feature request: output an error as json::Value or serde_json::Value directly #360

Closed
cdisselkoen opened this issue Mar 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@cdisselkoen
Copy link

miette has a JSONReportHandler which allows you to print errors as JSON. However, that results in writing text-format JSON to a fmt::Writer, and if you want the JSON as a json::Value or serde_json::Value, you have to re-parse the string AFAICT. (If I'm missing something or misunderstanding something, I apologize and please correct me :) )

It would be great if miette had a function for outputting an error directly as json::Value or serde_json::Value.

@zkat
Copy link
Owner

zkat commented Mar 29, 2024

miette does not have a dependency on serde_json or similar, and I think it should be up to end users to determine which Value type they want to use. As such, I don't think it's appropriate for miette itself to pull in a dependency like this, when it's trivial to do the parsing yourself. The cost of parsing the string will almost definitely be trivial, because in 99% of cases, displayed errors are relatively low-frequency things (since they're intended for human consumption).

As such, I'm inclined to decline this feature request. I just don't think the cost is worth the benefit.

@zkat zkat added the enhancement New feature or request label Mar 29, 2024
@cdisselkoen
Copy link
Author

That's reasonable. I'll close this.

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