-
Notifications
You must be signed in to change notification settings - Fork 115
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
Add ZValidation#toException #603
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I'm inclined to think we should just implement getOrElse
.
There isn't a generic way to convert a collection of E
values into a Throwable
. We're seeing that just discussing the implementation of these methods. Should it be an IllegalArgumentException
or not? Should it include the log? Should it use suppressed exceptions?
Since there isn't a generic way to do it we should just provide operators like fold
or getOrElse
that allow users to do it as easily as possible.
Sure there is 😃 I have extensive experience with Validated from cats, where I needed a functionality like this fairly often and had to do it myself, which was annoying, so I wanted to improve ZIO Prelude to make it more appealing compared to the competition. If we don't provide users with functions like The Good point about the |
Hmmm. My experience has been that organizations that use |
Sometimes it's just easier to throw the exception you're given, without necessarily creating a custom exception yourself for such situation. Sometimes creating a custom exception class is just overkill. With this PR merged, ZIO Prelude would have a choice to do that. Typically, it would be useful in situations where an error is really unexpected and happens only in case of a severe failure. But I've create a smaller PR, hopefully less controversial, with parts of functionality of this one: |
No description provided.