yaml/libyaml

Add advance error reporting for custom write_handler()

jasimmons1973 opened this issue · 0 comments

Currently libyaml handle the write_handler:

if (emitter->write_handler(emitter->write_handler_data,
emitter->buffer.start,
emitter->buffer.last - emitter->buffer.start)) {
emitter->buffer.last = emitter->buffer.start;
emitter->buffer.pointer = emitter->buffer.start;
return 1;
}
else {
return yaml_emitter_set_writer_error(emitter, "write error");
}

This means for custom write_handler any error is reported as "write error". I like to purpose is that we do

else {
return yaml_emitter_set_writer_error(emitter, emitter->problem ? emitter->problem : "write error");

This way if the custom write_handler sets the emitter->problem field we can use that information instead.