See the [Scaladoc](http://www.scala-lang.org/api/current/index.html#scala.util.Try) or the "For comprehensions" section of this post: http://danielwestheide.com/blog/2012/12/26/the-neophytes-guide-to-scala-part-6-error-handling-with-try.html

But seeing as the context is a closable resource, using [Scala ARM](https://github.com/jsuereth/scala-arm/blob/master/notes/about.markdown) would probably make even more sense here.