Skip to content

Instantly share code, notes, and snippets.

@Jacoby6000
Created March 11, 2015 23:20
Show Gist options
  • Save Jacoby6000/6bf910f533bb9e59628b to your computer and use it in GitHub Desktop.
Save Jacoby6000/6bf910f533bb9e59628b to your computer and use it in GitHub Desktop.
def someFunc(): Try[Int] = {
Try {
throw RuntimeException("Something bad happened!")
}
}
def callSomeFunc = {
val funcResult = someFunc()
funcResult match {
case Success(someIntVal) =>
//Do successful stuff using the return value of the try
case Failure(e) =>
//Handle exception
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment