frasertweedale / hs-jose

Haskell JOSE and JWT library
http://hackage.haskell.org/package/jose
Apache License 2.0
122 stars 46 forks source link

improve `CompactDecodeError` reporting #72

Closed frasertweedale closed 5 years ago

frasertweedale commented 5 years ago

Strings suck. Create a dedicated type to represent a compact representation decoding error and change the CompactDecodeError constructor to use it. Cases of JSON (aeson) decoding errors when processing a compact object should throw JSONDecodeError.

robx commented 5 years ago

Just to note that this change causes a rather redundant error formatting when using show:

Instead of

JWSError (CompactDecodeError "expected 3 parts, got 2")

I now see

JWSError (CompactDecodeError CompactDecodeError: Expected 3 parts; got 2)

in PostgREST output. (I'm not sure this is wrong, and should maybe be fixed by not just showing errors, but it does look a bit redundant.)

frasertweedale commented 5 years ago

@robx thanks, it's a bit of a brain-o, I pushed to master a commit improving this but I'm not in a hurry to release it, it will just get picked up in a future release.