Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. def someFunc(): Try[Int] = {
  2. Try {
  3. throw RuntimeException("Something bad happened!")
  4. }
  5. }
  6.  
  7. def callSomeFunc = {
  8. val funcResult = someFunc()
  9.  
  10. funcResult match {
  11. case Success(someIntVal) =>
  12. //Do successful stuff using the return value of the try
  13. case Failure(e) =>
  14. //Handle exception
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement