dynosaur icon indicating copy to clipboard operation
dynosaur copied to clipboard

More verbose error messages in `oneOf`

Open kubukoz opened this issue 3 years ago • 6 comments

I like the simplicity of the current error model (just a string is sometimes exactly what you want), but currently if a union fails to decode, you get virtually no information.

Combining the errors somehow would be great to have. Some ideas:

  • Either -> EitherNel (probably the most intrusive change)
  • ReadError as an ADT
  • just combining the strings to a larger string in the decoding logic for alternatives

kubukoz avatar Jul 09 '21 19:07 kubukoz

I actually have some notes on errors in general, the design space is not so trivial. I'm gonna share when I get some time

SystemFw avatar Jul 09 '21 19:07 SystemFw

Agreed, it's definitely not trivial 😅 especially if we consider error accumulation for records too.

kubukoz avatar Jul 09 '21 19:07 kubukoz

also toString for case class ReadError/WriteError is not showing actual message since both these classes are case classes and inherited from Throwable

semenodm avatar Apr 28 '22 19:04 semenodm

yeah, just hit this again - @SystemFw do you have bandwidth to give errors a closer look?

For @semenodm's toString issue we can probably to a quick workaround by adding a toString override.

kubukoz avatar Jun 13 '22 19:06 kubukoz

I'd take a PR to fix the immediate problem with toString, I don't know how long it'll be before I can look at the design more broadly

SystemFw avatar Jun 13 '22 20:06 SystemFw

I believe the #29 has addressed the issue partially: the resulting error now contains all the underlying branches failures

filosganga avatar May 05 '23 05:05 filosganga