title: Catching an exception within a map
body: <p>What is the best way of handling exceptions while iterating over a loop in Scala?</p>
  
  <p>For instance, if I had a <code>convert()</code> method that could throw an exception, I'd like to catch that exception, log it, and keep iterating.  Is there a "scala" way to do this?</p>
  
  <p>Ideally, I'd like something like...</p>
  
  <pre><code>val points: Seq[Point] = ...
  val convertedPoints: Seq[ConvertedPoint] = points.map(
     p =&gt; {
       try { p.convert() } 
       catch { case ex: Exception =&gt; logger.error("Could not convert", ex) }
  })
  </code></pre>
  
  <p>You can't do the above code since it's not a direct mapping from one list to the other (you get back <code>Seq[Any]</code> as opposed to <code>Seq[ConvertedPoint]</code>).</p>