I have the following code (simplified):
def getSomething(name: String): MyError \/ Option[Int] = {
/* Returns Null if name doesn't exist, IOException if connection err. */
val output: queryDB(name)
// ...
}
The queryDB function is a Java call.
I would like the following to happen: IOException mapped to MyError, and null to None. How should I proceed?
I am aware that I can wrap the output in an Option since null is mapped to None. However, how do I manage the exception?
Thanks.
scala.util.Trytoo, ieTry( Option( queryDB(name) ) )but old-school try / catch might just be simpler here.