i-json icon indicating copy to clipboard operation
i-json copied to clipboard

Appears to throw for both programmer and operational errors

Open Raynos opened this issue 8 years ago • 2 comments

I'd be nice if this library had a parser.result() vs parser.error() instead of throwing on invalid JSON.

Raynos avatar Apr 28 '16 23:04 Raynos

Well, I wanted to keep the API as simple as possible. More sophisticated APIs can always be scaffolded around this one. It would be very easy to wrap it with an evented API that emits result and error events.

One thing I should do though is throw different exception types. Today it's all Error.

bjouhier avatar Apr 30 '16 16:04 bjouhier

Thinking more about this, it would not be too hard to add an optional error callback to createParser. Only syntax errors would go through this callback. Programmer errors would still be thrown.

bjouhier avatar Apr 30 '16 17:04 bjouhier