1.7 KiB
1.7 KiB
Exceptions
MonadError
class Monad m => MonadError e (m :: * -> *) | m -> e where
throwError :: e -> m a
catchError :: m a -> (e -> m a) -> m a
Except
type Except e = ExceptT e Identity
Example:
ExceptT
newtype ExceptT e (m :: * -> *) a
= Control.Monad.Trans.Except.ExceptT (m (Either e a))
Example:
throwError
throwError :: MonadError e m => e -> m a
catchError
catchError :: MonadError e m => m a -> (e -> m a) -> m a
runExcept
runExcept :: Except e a -> Either e a
runExceptT
runExceptT :: ExceptT e m a -> m (Either e a)
Exceptions
class (Typeable e, Show e) => Exception e where
toException :: e -> SomeException
fromException :: SomeException -> Maybe e
GHC.Exception.displayException :: e -> String
throwIO
throwIO :: (MonadIO m, Exception e) => e -> m a
throwSTM
throwSTM :: Exception e => e -> STM a
throwTo
throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m ()
Utilities
hush
hush :: Alternative m => Either e a -> m a
note
note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a
tryIO
tryIO :: MonadIO m => IO a -> ExceptT IOException m a
Fatal Errors
data FatalError = FatalError {fatalErrorMessage :: Text}
panic
panic :: Text -> a
Terminate with an uncatchable fatal error.
> panic "Fatal error occured.