Add additional constructors for Try object
#21545
tmccombs
started this conversation in
Feature Requests
Replies: 1 comment
-
|
https://www.scala-lang.org/files/archive/api/current/scala/util/control/Exception$.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Try.applycurrently returns aFailureif aNonFatalexception is thrown in the block.However, that often isn't what is actually desired.
In fact, in #17737 it was discussed that
NonFatalshould be deprecated, perhaps in favor of just catchingExceptioninstead (in particular, see #17737 (comment)).It may also often be desirable to create a Try, but propagate
Breakexceptions, so that it can be used in a Boundary, for example in something like this:Currently, this would loop forever, since the Try would catch the
Breakexception. It would be nice if there was an easy to use method onTryto create aTrythat lets throughBreakexceptions, but catches other exceptions.Something like:
Some other possible types of conditions that may be useful to have additional methods for:
Although I'm not sure how useful those would be.
Some other related ideas
It would probably be valuable to have a
NonControlmatcher or maybeNonBreakdefined something like:I also wonder if it would be worth having a method on the
Trytrat like:Beta Was this translation helpful? Give feedback.
All reactions