blob: fe12a62329bee9a6d57a0a49877d5bb8fcb77ee7 (
plain) (
tree)
|
|
import java.io.IOException
import java.lang.NullPointerException
import java.lang.IllegalArgumentException
object IAE {
def unapply(e: Exception): Option[String] =
if (e.isInstanceOf[IllegalArgumentException]) Some(e.getMessage)
else None
}
object EX extends Exception
trait ExceptionTrait extends Exception
object Test {
def main(args: Array[String]): Unit = {
var a: Int = 1
try {
throw new IllegalArgumentException()
} catch {
case e: IOException if e.getMessage == null =>
case e: NullPointerException =>
case e: IndexOutOfBoundsException =>
case _: NoSuchElementException =>
case _: ExceptionTrait =>
case _: NoSuchElementException if a <= 1 =>
case _: NullPointerException | _:IOException =>
case `a` => // This case should probably emmit an error
case e: Int => // error
case EX =>
case IAE(msg) =>
case e: IllegalArgumentException =>
}
}
}
|