-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Don't infer Null in fromTryCatch #592
Conversation
I also renamed `fromTryCatch` to `catching`, because it's a bit less verbose and I like the sound of it a little more. I can change it back if people would prefer though.
By the way, this is what happens now if you omit the type parameter on
|
Looking at that error message, I'm a bit tempted to hack around the fact that you can't do something like |
Using descriptive method names there sounds smart. |
Also, I feel like we talked about this before, but how would you feel about a simpler variation that was something like this: def catching(body: => A): Xor[Throwable, A] =
try { Right(body) } catch { case e: NonFatal => Left(e) } Often when working with exceptions I don't care about the type, and the syntax is a lot nicer if you can leave off the annotations. EDIT: Somehow I completely missed the fact that you defined this as |
@ceedubs: you’ve probably seen this, but:
in scala 2.12.0-M3 |
@refried @puffnfresh I didn't know about @non is you preference for |
And also use a slightly ridiculous name for one of the ambiguous NotNull[Null] instances to steer people in the right direction.
Current coverage is
|
I've updated my PR. What do people think? Specifically @non and @mpilquist, since both of you discussed this with me. Also big thanks to @tpolecat because tut caught several places where I had neglected to update the documentation after these changes :) |
This seems fine to me. 👍 (I think I'd prefer |
Don't infer Null in fromTryCatch
This is the start of a fix for #591. So far I've only change
Xor
, because I wanted to run this approach by people. If people like this approach, then I can also updateValidated
and try to add some more tests to this PR.I also renamed
fromTryCatch
tocatching
, because it's a bit less verbose and I like the sound of it a little more. I can change it back if people would prefer though.