ResumableParser#parse swallows a JSON::ParserError raised inside on_load.
require "json"
parser = JSON::ResumableParser.new(on_load: ->(o) do
JSON.parse("") #=> raises JSON::ParserError
o
end)
parser << "[1]"
parser.parse
# expected: raises JSON::ParserError
# actual: parse returns false (the error is swallowed)
This happens because the current implementation wraps parsing in rb_protect. Could exceptions raised inside on_load be re-raised? I'm a bit concerned about the overhead, though. If we do not, it would be good to document the behavior.
ResumableParser#parseswallows aJSON::ParserErrorraised insideon_load.This happens because the current implementation wraps parsing in
rb_protect. Could exceptions raised inside on_load be re-raised? I'm a bit concerned about the overhead, though. If we do not, it would be good to document the behavior.