This is basically to wrap java factory methods which throw exceptions if the item can\'t be created based on the inputs. I\'m looking for something in the base library like:
Use scala.util.control.Exception:
import scala.util.control.Exception._
allCatch opt f
And you can make it more sophisticated. For example, to catch only arithmetic exceptions and retrieve the exception:
scala> catching(classOf[ArithmeticException]) either (2 / 0)
res5: Either[Throwable,Int] = Left(java.lang.ArithmeticException: / by zero)