mongoDB-0.7: A driver for MongoDB

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) 
Throw IOError m => Throw IOError (Connected m) 
Monad m => Throw Failure (Connected 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