Reputation: 6404
I am trying to catch different types of exceptions but I am stuck on an error. I imported scala.util.control.Exception._
try {
isAuthenticatedJson(f)
}catch {
//object RuntimeException is not a value
case RuntimeException => {}
//object Exception is not a value
case Exception => {}
}
What am I missing?
Upvotes: 2
Views: 2415
Reputation: 32739
Try this (note the underscore):
try {
isAuthenticatedJson(f)
} catch {
case _: RuntimeException => {}
case _: Exception => {}
}
This is a "typed pattern". See http://www.scala-lang.org/node/120.
Upvotes: 13