You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code should throw no exceptions e.g. when pasted into the REPL. The solution in each case is the same: to wrap the call to the offending function or by-name parameter in the standard try/catch block.
importutil.Tryvala="apple"deffail:String=thrownewException("Fail!")
defargh:Try[String] =thrownewException("Argh!")
// None of these should throw anythingTry(fail).orElse(argh) // In TryTry(a).transform(_ => argh, _ => argh) // In TryTry(fail).transform(_ => argh, _ => argh) // In TryTry(fail).recoverWith{ case e if (a==fail) =>Try(a) } // In FailureTry(fail).recoverWith{ case _ => argh } // In failure
The text was updated successfully, but these errors were encountered:
The following code should throw no exceptions e.g. when pasted into the REPL. The solution in each case is the same: to wrap the call to the offending function or by-name parameter in the standard try/catch block.
The text was updated successfully, but these errors were encountered: