purescript-contrib/purescript-argonaut-codecs

Use `elaborateFailure` in `getFieldOptional'`

LucianU opened this issue · 4 comments

The function getFieldOptional uses elaborateFailure which displays the key for a value that couldn't be decoded. Unfortunately, getFieldOptional' doesn't use this function, so please consider adding it.

See here:

decode json = Just <$> (elaborateFailure s <<< decodeJson) json

I'm surprised it's not used in both and I can't think of a reason why not other than an oversight. For now I'm labeling this for a new contributor to the library to pick up as their first contribution, but if no one jumps in to add it I'll come back to it.

I could add that line, but I didn't do it, because I read in the contribution guidelines, that also tests are required. I didn't know what that entailed, so that's why I didn't move forward.

In this case, the failure is already covered by another test case for the non-prime version of the function. So I'd be willing to merge a PR that simply added this small change without a corresponding test (though I do ask that you still do a quick manual sanity check!)

Closed in #52 -- thanks!