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 © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland