fork download
  1. class Exception1 extends Exception
  2. class Exception2 extends Exception
  3. class Exception3 extends Exception
  4.  
  5. object Main {
  6. def main(args: Array[String]) {
  7. try {
  8. throw new Exception2()
  9. } catch {
  10. case x => {
  11. println("Exception")
  12. println(x match {
  13. case _: Exception1 => "1"
  14. case _: Exception2 => "2"
  15. case _: Exception3 => "3"
  16. case _ => "Unknown"
  17. })
  18. }
  19. }
  20. }
  21. }
Success #stdin #stdout 0.24s 247424KB
stdin
1
2
10
42
11
stdout
Exception
2