You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 std::vector<std::string> of all missing keys. However, I don't generally want this within glz::context and affect performance even when error_on_missing_keys is false.
I'm thinking of having a static thread_local function that provides the missing keys. An idea for how it would be used is below:
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
}
}
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: