mongoDB-0.9.2: MongoDB driver

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.

Synopsis

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

throw :: e -> m aSource

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

Instances

Error e => Throw e (Either e) 
Monad m => Throw Failure (Action m) 
Throw e m => Throw e (ReaderT x m) 
(Error e, Throw e m, Error x) => Throw e (ErrorT x m) 
(Error e, Monad m) => Throw e (ErrorT e m) 

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

mapError :: Functor m => (e -> e') -> ErrorT e m a -> ErrorT e' m aSource

Convert error type