Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Implement better path and type reporting in error messages #219

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

klundberg
Copy link

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 klundberg changed the title Full path errors Implement better path and type reporting in error messages Jan 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant