Scala Library
|
|
scala/util/control/Exception.scala
]
object
Exception
extends
AnyRefimport scala.util.control.Exception._ import java.net._ val s = "http://www.scala-lang.org/" val x1 = catching(classOf[MalformedURLException]) opt new URL(s) val x2 = catching(classOf[MalformedURLException], classOf[NullPointerException]) either new URL(s)
Type Summary | |
type
|
Catcher |
type
|
ExceptionCatcher |
Value Summary | |
final val
|
noCatch
: Catch[Nothing]
The empty Catch object.
|
final val
|
nothingCatcher : PartialFunction[java.lang.Throwable, Nothing] |
Method Summary | |
final def
|
allCatch
[T] : Catch[T]
A Catch object which catches everything.
|
def
|
catching [T](c : PartialFunction[T]) : Catch[T] |
def
|
catching
[T](exceptions : java.lang.Class[Any]*) : Catch[T]
Creates a Catch object which will catch any of the supplied exceptions.
Since the returned Catch object has no specific logic defined and will simply
rethrow the exceptions it catches, you will typically want to call "opt" or
"either" on the return value, or assign custom logic by calling "withApply".
|
def
|
failing
[T](exceptions : java.lang.Class[Any]*) : Catch[Option[T]]
Creates a Catch object which maps all the supplied exceptions to 'None'.
|
implicit def
|
fromExceptionCatcher [T](pf : PartialFunction[T]) : PartialFunction[T] |
def
|
handling [T](exceptions : java.lang.Class[Any]*) : By[(java.lang.Throwable) => T, Catch[T]] |
def
|
ignoring
(exceptions : java.lang.Class[Any]*) : Catch[Unit]
Creates a Catch object which catches and ignores any of the supplied exceptions.
|
def
|
saving
[A](oldVal : A, newVal : A, setter : (A) => Unit) : Catch[Nothing]
Experimental
|
def
|
ultimately
[T](body : => Unit) : Catch[T]
Returns a Catch object with no catch logic and the argument as Finally.
|
def
|
unwrapping
[T](exceptions : java.lang.Class[Any]*) : Catch[T]
Creates a Catch object which unwraps any of the supplied exceptions.
|
Methods inherited from AnyRef | |
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
Methods inherited from Any | |
==, !=, isInstanceOf, asInstanceOf |
Class Summary | |
class
|
By
[T, R](f : (T) => R) extends AnyRef
Returns a partially constructed Catch object, which you must give
an exception handler function as an argument to "by". Example:
handling(ex1, ex2) by (_.printStackTrace)
|
class
|
Catch
[+T](val pf : PartialFunction[T], val fin : Option[Finally]) extends Described
A container class for catch/finally logic.
|
trait
|
Described
extends AnyRef
|
class
|
Finally
(body : => Unit) extends Described
A container class for finally code.
|
class
|
Try
[+T](body : => T, val catcher : Catch[T]) extends AnyRef
A container class for Try logic
|
Type Details |
Value Details |
Method Details |
implicit
def
fromExceptionCatcher[T](pf : PartialFunction[T]) : PartialFunction[T]
def
catching[T](exceptions : java.lang.Class[Any]*) : Catch[T]
def
catching[T](c : PartialFunction[T]) : Catch[T]
def
ignoring(exceptions : java.lang.Class[Any]*) : Catch[Unit]
def
failing[T](exceptions : java.lang.Class[Any]*) : Catch[Option[T]]
def
handling[T](exceptions : java.lang.Class[Any]*) : By[(java.lang.Throwable) => T, Catch[T]]
def
unwrapping[T](exceptions : java.lang.Class[Any]*) : Catch[T]
Scala Library
|
|