Unbox icon indicating copy to clipboard operation
Unbox copied to clipboard

Implement better path and type reporting in error messages

Open klundberg opened this issue 7 years ago • 0 comments

Resolves #165

This PR improves the error messaging in Unbox to show the full path through the JSON being parsed so that it's obvious where the error is happening.

This implementation differs slightly from the one proposed in that issue, in that it uses plain dot syntax for array indices instead of subscripting (thing.2.property instead of thing[2].property). It shouldn't be hard to change this if subscripting is desired, but I used dot syntax to stay in sync with unbox's keypath syntax for querying into arrays, which looks like it uses dot syntax.

I've also added type information to some of the errors, so that if there's a type unboxing error, you can know exactly what types are being used and add the appropriate protocol conformances to make them work if the JSON data is correct.

Tests have also been added for all the cases I could think of that exercise these new error enhancements.

I hope this helps! Let me know if there's any issues. I'd love to get this integrated quickly :)

klundberg avatar Jan 15 '18 18:01 klundberg