Add advance error reporting for custom write_handler()

Open
#273 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c
Domain
backend

Research direction

Start at the emitter code that invokes the custom write_handler and the yaml_emitter_set_writer_error entry point. Check how the emitter->problem field is populated, then verify that a custom handler's supplied problem is reported while the existing "write error" fallback remains; add or update coverage if the repository has relevant emitter tests.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C
Stars
1.2k
Forks
370
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from yaml/libyaml

All issues in yaml/libyaml

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.