purescript-contrib / purescript-argonaut-codecs

JSON serialization and deserialization with Argonaut.
MIT License
48 stars 46 forks source link

Decode error reporting #39

Closed kika closed 5 years ago

kika commented 6 years ago

The majority of decoders in 'Data.Argonaut.Decode' complain about errors without providing context for the error. For example Couldn't decode StrMap: Value is not a String. When parsing a large JSON blob with a lot of different structures in it, it's quite hard to figure out what exactly is the problem. Some decoders though, do provide at least the value which triggered the error: https://github.com/purescript-contrib/purescript-argonaut-codecs/blob/fa2cbbbc553033761e522d22d5e07904a830ab5b/src/Data/Argonaut/Decode/Class.purs#L68

I can submit a PR doing the same for the rest of the decoders.

thomashoneyman commented 5 years ago

@kika this is absolutely a valuable thing to add! Chris Cornwell merged some code that serves the same purpose recently (https://github.com/purescript-contrib/purescript-argonaut-codecs/pull/44) but there is still the opportunity to do more.

I know this is a very late response, but please do feel free to add better error reporting. I've joined the contrib organization specifically to stay on top of things like this and make sure your issues / PRs are promptly addressed. If you open a PR with this functionality then I will be sure to respond within a day or two.

I will leave this issue open for a few days in case you'd like to continue the conversation, and then I'll close it.

kika commented 5 years ago

44 looks good to me! I'm not actively developing this project right now, but will get back to it in a few months and then will see if I still need improvement in this area and if yes will take on that.