rapidyaml icon indicating copy to clipboard operation
rapidyaml copied to clipboard

Request: Add more context to error traces

Open mcandre opened this issue 1 year ago • 3 comments

rapidyaml often reports check failed: (ch != NONE) when attempting to traverse YAML data that omits expected keys.

In large applications, most users will be confused by this message, unable to take action to correct the mistake.

Can we please present more specific error messages. For example, indicate the name of the YAML key that the application was attempting to lookup.

mcandre avatar Jan 16 '24 20:01 mcandre

Thats what I meet either. I make a wrapper for the lower level API usages. Its not easy and costs lots of time. Maybe a more detailed error trace messages should be added by ryml.

emmett2020 avatar Jan 19 '24 04:01 emmett2020

I agree that the error messages could be improved. I am revisiting this in the context of #389 and I will devise a better solution.

biojppm avatar Apr 01 '24 13:04 biojppm

Actually this fix missed the boat on #389.

I'm thinking of adding a second error handler for node visitation:

// existing error handler: tuned for parsing
using pfn_error = void (*) (const char* msg, size_t msg_len, Location location, void *user_data);

// to be added: tuned for visiting
using pfn_error_visit = void (*) (const char* msg, size_t msg_len, Tree const& tree, size_t id, void *user_data);

But this involves a thorough look at the existing calls, so it will have to wait for ongoing work to be merged in (specifically #414 which is giant).

biojppm avatar Apr 14 '24 12:04 biojppm