Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZValidation: add toEitherException, toFuture and make toTry not discard errors #803

Open
wants to merge 3 commits into
base: series/1.x
Choose a base branch
from

Conversation

sideeffffect
Copy link
Member

@sideeffffect sideeffffect commented Nov 13, 2021

Related issue #791

Lighter version of these PRs:
closes #610
closes #603

final case class Success[+W, +A](log: Chunk[W], value: A) extends ZValidation[W, Nothing, A]

object Failure {
final case class Exception[+W, +E](failure: Failure[W, E])(implicit ev: E <:< Throwable)
Copy link
Contributor

Choose a reason for hiding this comment

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

We're exposing a lot of implementations details here and we are also potentially creating some inaccurate information. The returned Throwable is a subtype of RuntimeException even though it is possible that none of the original throwable are subtypes of RuntimeException. I would suggest we just take the first error and then add the others as suppressed exceptions to that, discarding the log. There are a variety of other operators that users can use to get the log if they want.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean to mutate an existing Exception by adding others as suppressed? Wouldn't that be a bit misleading? How could users recognize the original suppressed exceptions in that particular Exception from those that we would add?

Or do you think it would be better to use a mere Exception instead of RuntimeException.

I don't have a strong opinion on this, so let me know, if you still think adding rest as suppressed to the first one is the best way to go.

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.

None yet

2 participants