Function sample_error_handler
Synopsis
#include <samples/quickstart.cpp>
void sample_error_handler()
Description
set a custom error handler
demonstrates how to set a custom error handler for ryml
Mentioned in
- Getting Started / Quick start
Source
Lines 3459-3472 in samples/quickstart.cpp. Line 73 in samples/quickstart.cpp.
void sample_error_handler()
{
ErrorHandlerExample errh;
ryml::set_callbacks(errh.callbacks());
errh.check_effect(/*committed*/true);
errh.check_error_occurs([]{
ryml::Tree tree = ryml::parse("errorhandler.yml", "[a: b\n}");
std::cout << tree;
});
ryml::set_callbacks(errh.defaults); // restore defaults.
errh.check_effect(/*committed*/false);
}