Error messages lost for recusive decoders
See original GitHub issueWhen using emap
to create a custom validation for a recusive decoder the error messages are lost for the parts of the object which are decoded recursively:
import io.circe._, io.circe.generic.semiauto._, io.circe.generic.decoding.DerivedDecoder, io.circe.generic.encoding.DerivedObjectEncoder
case class A(i: Int, l: List[A])
def validA(a: A): Boolean = {
a.i > 0 && a.l.map(validA).foldLeft(true)(_ && _)
}
implicit val ae: Decoder[A] = deriveDecoder[A].emap { a =>
if(!validA(a)) {
Left("Bad!")
} else {
Right(a)
}
}
val s = """{"i":1, "l": [{"i": -1, "l": []}, {"i": 2, "l": []}]}"""
parser.parse(s).right.get.as[A]
When running the last line of code you get
io.circe.Decoder.Result[A] = Left(DecodingFailure([A]List[A], List(DownArray, DownField(l))))
Which is a valid decoding failure, but the error message of [A]List[A]
isn’t what is expected. I would expect Bad!
or something similar to DecodingFailure at .l[0]: Bad!
I’m using circe 0.7.0 for reference. And this issue was originally raised in the gitter channel
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Recursive decoding and its performance for low-rate Reed ...
error weights for which the decoding error probability vanishes on the entire sequence of decoding steps as the code length grows.
Read more >Recursive List Decoding for Reed-Muller Codes and ... - arXiv
Abstract. We consider recursive decoding for Reed-Muller (RM) codes and their subcodes. Two new recursive techniques are described.
Read more >Compiler error for recursive decoder using glennsl/rescript ...
I've run into a compiler error I think I need some help with while trying to create a recursive decoder using ...
Read more >Decoding recursive JSON in Elm - Korban.net
In this post, I'd like to tell the story of implementing recursive decoders. The path to a recursive decoder. The basic structure of...
Read more >Recursive List Decoding for Reed-Muller Codes and Their ...
We consider recursive decoding for Reed-Muller (RM) codes and their subcodes. Two new recursive techniques are described. We analyze asymptotic properties ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it is fixed by https://github.com/circe/circe/pull/649
@EdgeCaseBerg Normally I’ve been closing issues when the fix hits master. If it’s really urgent I could backport this for an 0.8.1, but I’m guessing 0.9 is less than a week off and I wouldn’t be able to get 0.8.1 out until Saturday anyway.