Failing with error causes an exception to be thrown while decoding the value, as opposed to a nice error message with a JSON path when the parser fails with Prelude.fail.
Before:
$ eitherDecode "true" :: Either String DBKey
*** Exception: Expected Number or Null
CallStack (from HasCallStack):
error, called at .../postgresql-orm/src/Database/PostgreSQL/ORM/Model.hs:169:17 in main:Database.PostgreSQL.ORM.Model
With this PR:
$ eitherDecode "true" :: Either String DBKey
Left "Error in $: Expected Number or Null"
Note that the issue isn't just the error message, the exception is usually very unexpected coming out of JSON decoding.
Failing with error causes an exception to be thrown while decoding the value, as opposed to a nice error message with a JSON path when the parser fails with Prelude.fail.
Before:
With this PR:
Note that the issue isn't just the error message, the exception is usually very unexpected coming out of JSON decoding.