In our codebase we can use functions/method we have no control over which can throw errors. If we want to keep these errors contained we could encapsulate them in the Either monad. A constructor of the type Either.fromThrowable(throwableMethod()) could solve the problem.
fromThrowable should:
Catch the exception error and fill the Error side of Either
If the function does not throw it should fill the Ok side of Either
In our codebase we can use functions/method we have no control over which can throw errors. If we want to keep these errors contained we could encapsulate them in the Either monad. A constructor of the type
Either.fromThrowable(throwableMethod())
could solve the problem.fromThrowable
should:Error
side ofEither
Ok
side ofEither