Skip to content

Conversation

@ChristopherDavenport
Copy link

A conjecture of an approach, I suspect most of the accumulator code can instead be removed and rewritten in terms of this mechanic.

Needs a bit more of the replication of a case class machinery that the SingleDecodingFailure has, but as you can see in the added test, makes it very easy to do error accumulation.

@codecov-io
Copy link

Codecov Report

Merging #1243 into master will decrease coverage by 0.48%.
The diff coverage is 70.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1243      +/-   ##
==========================================
- Coverage   86.44%   85.96%   -0.49%     
==========================================
  Files          92       92              
  Lines        2863     2879      +16     
  Branches      119      118       -1     
==========================================
  Hits         2475     2475              
- Misses        388      404      +16
Impacted Files Coverage Δ
.../core/shared/src/main/scala/io/circe/Decoder.scala 85.71% <66.66%> (+0.88%) ⬆️
...es/core/shared/src/main/scala/io/circe/Error.scala 61.36% <71.42%> (-1.14%) ⬇️
.../core/shared/src/main/scala/io/circe/ACursor.scala 50% <0%> (-21.43%) ⬇️
...rc/main/scala/io/circe/shapes/SizedInstances.scala 78.57% <0%> (-14.29%) ⬇️
...d/src/main/scala/io/circe/NonEmptySeqDecoder.scala 91.66% <0%> (-8.34%) ⬇️
...re/shared/src/main/scala/io/circe/JsonNumber.scala 91.56% <0%> (-2.41%) ⬇️
...les/core/shared/src/main/scala/io/circe/Json.scala 76.96% <0%> (-1.22%) ⬇️
...rc/main/scala/io/circe/numbers/BiggerDecimal.scala 85.38% <0%> (-1.17%) ⬇️
...re/shared/src/main/scala/io/circe/KeyDecoder.scala 97.29% <0%> (+2.7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3edf83c...19c52e8. Read the comment docs.

@travisbrown
Copy link
Member

I want to go ahead and publish 0.12.0, but we'll work through this in the 1.0.0 milestones.

@ChristopherDavenport
Copy link
Author

That sounds good. .mapN works as well as .parMapN for my decoders presently. I do feel this is a major optimization to get all the errors though, which will help with client debugging etc in a faster iteration cycle.

*/
sealed abstract class DecodingFailure(val message: String) extends Error {
sealed trait DecodingFailure extends Error {
val message: String
Copy link

@jeffmay jeffmay Sep 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not add the def withMessage(message: String): DecodingFailure method here?

_.map(
e =>
e match {
case e: SingleDecodingFailure => e.withMessage(message)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just flatten this to:

_.map {
  case e: SingleDecodingFailure     => e.withMessage(message)
  case e: AggregatedDecodingFailure => e.withMessage(message)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants