Scala: scala.util.Try
The type scala.util.Try
is an operation that may result in either an exception or a valid output. Let’s explore a few of its usages, including single and chained calls to scala.util.Try.
The Try
operation will result in either a Success or Failure. To simplify, think about it an Either
for successes and failures instead of Left
and Right
, but proper for encapsulating exceptions instead of other arbitrary values.