diff --git a/jsonl/Parser.js b/jsonl/Parser.js index 409b76b..9b0e403 100644 --- a/jsonl/Parser.js +++ b/jsonl/Parser.js @@ -11,7 +11,7 @@ class JsonlParser extends Utf8Stream { try { return JSON.parse(input, reviver); } catch (error) { - if (typeof errorIndicator == 'function') return errorIndicator(error); + if (typeof errorIndicator == 'function') return errorIndicator(error, input, reviver); } return errorIndicator; } diff --git a/tests/test_jsonl.js b/tests/test_jsonl.js index 1e2e1ff..4f03c93 100644 --- a/tests/test_jsonl.js +++ b/tests/test_jsonl.js @@ -294,6 +294,24 @@ unit.add(module, [ async.done(); }); + readString('{\n1\n]\n2\n3').pipe(stream); + }, + function test_jsonl_transform_errors_forward(t) { + const async = t.startAsync('test_jsonl_transform_errors_forward'); + + const stream = parser({errorIndicator: (e, val) => val}), + result = []; + + stream.on('data', data => result.push(data)); + stream.on('error', err => { + eval(t.TEST("!'We shouldn't be here.'")); + async.done(); + }); + stream.on('end', value => { + eval(t.TEST("t.unify(result, [{key: 0, value: '{'}, {key: 1, value: 1}, {key: 2, value: ']'}, {key: 3, value: 2}, {key:4, value: 3}])")); + async.done(); + }); + readString('{\n1\n]\n2\n3').pipe(stream); } ]);