-
Notifications
You must be signed in to change notification settings - Fork 143
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
Enhance missing_key
error message
#1148
Comments
Thanks for pointing this out. The plan is to make the glz::context more generic, which would allow custom error messages, and I'll also take missing keys into account. We should be able to report at least one missing key. I'd like to report all missing keys, but want to be careful about avoiding dynamic allocations in the error handling code. |
I think we want to report all keys that are missing. This would be easiest to handle as a I'm thinking of having a auto ec = glz::read_json(obj, buffer);
if (ec == glz::error_code::missing_key) {
const std::vector<std::string>& missing_keys = glz::missing_keys();
for (auto& key : missing_keys) {
// do something with the reported missing keys
}
} |
Adding notes for future implementation: I have a path forward for much better compile time option handling, I think this should be done before context changes, but done with context changes in mind. |
Currently the error message for missing keys is simply
"missing_key"
and a location pointing to the end of the object. For some applications I would feel uncomfortable showing that error to a user that is supposed to manually edit JSON files.Is there a way to add a more descriptive error that mentions the missing key? I know that the error context does not have much space for information like that. Maybe
includer_error
could be abused for this?The text was updated successfully, but these errors were encountered: