This page is no longer maintained — Please continue to the home page at www.scala-lang.org

How can I catch exceptions?

Use try and catch, where the catch clause is a pattern match.

   try { 
   // ... 
   } catch {
     case ioe: IOException => ... // more specific cases first !
     case e: Exception => ...
   }

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland