Control.Monad.Throw
Description
This is just like Control.Monad.Error.Class except you can throw/catch the error of any ErrorT in the monad stack instead of just the top one as long as the error types are different. If two or more ErrorTs in the stack have the same error type you get the error of the top one.
Documentation
class Monad m => Throw e m whereSource
Same as MonadError
but without functional dependency so the same monad can have multiple errors with different types
Methods
Abort action and throw give exception. Analogous to throwError
.
catch :: m a -> (e -> m a) -> m aSource
If first action aborts with exception then execute second action. Analogous to catchError
throwLeft :: Throw e m => m (Either e a) -> m aSource
Execute action and throw exception if result is Left, otherwise return the Right result
throwLeft' :: Throw e m => (x -> e) -> m (Either x a) -> m aSource
Execute action and throw transformed exception if result is Left, otherwise return Right result
onException :: Throw e m => m a -> (e -> m b) -> m aSource
If first action throws an exception then run second action then re-throw