Pretty-printing of decoding failure history
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 546
- Avg merge
- 5d 16h
- Merged PRs (30d)
- 1
Description
From gitter: https://gitter.im/travisbrown/circe?at=56b1d0786b6468374a0b2b7c
Consider the following example:
``` scala
scala> val json = parse("""[1, 2, "hello", 4, "world", 6]""").getOrElse(Json.empty)
scala> Decoder[List[Int]].apply(json.hcursor)
res5: io.circe.Decoder.Result[List[Int]] = Left(io.circe.DecodingFailure: Int: El(MoveRight,true),El(MoveRight,true),El(DownArray,true))
```
This part might be hard to parse for a human eye:
``` scala
io.circe.DecodingFailure: Int: El(MoveRight,true),El(MoveRight,true),El(DownArray,true)
```
I guess we could improve the error message by reversing a history, making it a bit more visual, and maybe adding the element we failed to parse. Something along these lines:
```
[↴ array]
→|→ × Failed to decode hello as Int
```
I'm not sure about arrow symbols though (on github they are very tiny), so maybe just printing
```
[down array]
[right], [right] × Failed to decode hello as Int
```
Contributor guide
Research direction
Start with the DecodingFailure output produced by Decoder[List[Int]] and the history shown in the issue. Compare the current history rendering with the proposed array and right-movement formats, including the failed value and target type. Done means the decoding failure is easier to read and the chosen format is covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100