Execute the provided callback, wrapping the return value in Ok
or
Err(error)
if there is an exception.
const aSuccessfulOperation = () => 2 + 2;
const anOkResult = Result.tryOr('Oh noes!!1', () => {
aSuccessfulOperation()
}); // => Ok(4)
const thisOperationThrows = () => throw new Error('Bummer');
const anErrResult = Result.tryOr('Oh noes!!1', () => {
thisOperationThrows();
}); // => Err('Oh noes!!1')
The error value in case of an exception
Execute the provided callback, wrapping the return value in
Ok
orErr(error)
if there is an exception.