title: How to deal with exceptions in Scala Futures?
body: <p>I implemented a simple job processor that processes subjobs within futures (scala.actors.Futures). These futures themselves can create more futures for processing subjobs. Now, if one of these subjobs throws an exception, i want the job processor to reply with an error message for that job. I have a workaround solution for discovering failed subjobs, but i'm not sure if that's the best solution. Basically it works like this:</p>
  
  <pre><code>sealed trait JobResult
  case class SuccessResult(content: String) extends JobResult
  case class FailedResult(message: String) extends JobResult
  
  for(subjob &lt;- subjobs) yield {
    future {
      try {
            SuccessResult(process(subjob))
      } catch {
        case e:Exception =&gt; FailedResult(e.getMessage)                              
      }
    }
  }
  </code></pre>
  
  <p>The result at the top level is a recursive List of Lists of Lists... of JobResults. I recursively search the List for a failed Result and then return an error or the combined result depending on the types of results. 
  That works but i'm wondering if there's is a more elegant/easier solution for dealing with exceptions in futures?</p>