circe icon indicating copy to clipboard operation
circe copied to clipboard

Use Show to provide Exception message for DecodingFailure

Open tmccarthy opened this issue 5 years ago • 1 comments

Overview

I'm proposing that getMessage in DecodingFailure be changed to use the showDecodingFailure implementation so as to improve the readability of stacktraces generated by decoding failures.

If this change is welcome I am happy to submit a PR.

Current situation

DecodingFailure provides showDecodingFailure, which provides a compact, human-readable representation of a decoding failure. In particular, it makes it relatively easy to identify where in a document the cursor has failed.

By contrast, the overridden getMessage method returns a much less descriptive message, using the bare toString for CursorOp. Because this message is included in the stacktrace for DecodingFailure, in my experience it is much more likely to end up in logs.

For example, compare the following (from a project I'm working on):

DecodingFailure at [3].stateBranches[3].prominentPartyId: [A]Option[A]

versus

DecodingFailure([A]Option[A], List(DownField(prominentPartyId), MoveRight, MoveRight, MoveRight, DownArray, DownField(stateBranches), MoveRight, MoveRight, MoveRight, DownArray))

tmccarthy avatar May 22 '20 04:05 tmccarthy

Oh it looks like there's already a PR for this #1316.

tmccarthy avatar May 24 '20 01:05 tmccarthy