elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Nullable Json decode error message #247

Closed saleemjaffer closed 6 years ago

saleemjaffer commented 6 years ago

I have a JSON where the value for a key is be nullable. The value for this key is a complex-ish JSON object. If the value is an incorrect JSON, the decoder fails and the compiler just complains saying The value is expected to be null but it is .... It is hard to figure out what actually is wrong since the JSON is complex. Can we get a better error message for this?

I use Json.Decode.nullable to decode this nullable JSON.

evancz commented 6 years ago

I do not have enough info here to address this in particular without an http://sscce.org/

That said, I have done a bunch of work on the Json.Decode library to produce nicer error messages. Ones that people can customize to show things however they want. So my recommendation would be to see if it's as bad in 0.19, and if so, open an issue on the elm-lang/json repo with an SSCCE.

Sorry for the difficulty in the meantime, and thank you for letting us know!