Creating Results
Create a new Result
by using smart constructor methods
Result.valid(42) ==== Valid(42)
Result.invalid(1337) ==== Invalid(1337)
from a Try
Result.fromTry(Try(42)) ==== Valid(42)
Result.fromTry(Try(throw Error)) ==== Invalid(Error)
from an Either
Result.fromEither(Right(42)) ==== Valid(42)
Result.fromEither(Left(1337)) ==== Invalid(1337)
from an Option
Result.fromOption(Some(42), 1337) ==== Valid(42)
Result.fromOption(None, 1337) ==== Invalid(1337)
by catching a specific exception
Result.catching[Error].run(42) ==== Valid(42)
Result.catching[Error].run(throw Error) ==== Invalid(Error)
Result.catching[Error].using(_.getMessage).run(throw Error) ==== Invalid("error")