Scala: Can't catch exception thrown inside a closure
Posted
by Dmitriy
on Stack Overflow
See other posts from Stack Overflow
or by Dmitriy
Published on 2010-04-17T03:01:45Z
Indexed on
2010/04/17
3:03 UTC
Read the original article
Hit count: 277
Disclaimer: absolute novice in Scala :(
I have the following defined:
def tryAndReport(body: Unit) : Unit = {
try {
body
} catch {
case e: MySpecificException => doSomethingUseful
}
}
I call it like this:
tryAndReport{
someCodeThatThrowsMySpecificException()
}
While the call to someCodeThatThrowsMySpecificException happens just fine, the exception is not being caught in tryAndReport.
Why?
Thank you!
© Stack Overflow or respective owner