Files
postgrest/docs/Exceptions.md
T
2016-12-10 16:01:47 +00:00

1.4 KiB

Exceptions

MonadError

class Monad m => MonadError e (m :: * -> *) | m -> e where
  throwError :: e -> m a
  catchError :: m a -> (e -> m a) -> m a
type Except e = ExceptT e Identity
newtype ExceptT e (m :: * -> *) a
  = Control.Monad.Trans.Except.ExceptT (m (Either e a))
throwError :: MonadError e m => e -> m a
catchError :: MonadError e m => m a -> (e -> m a) -> m a
runExcept :: Except e a -> Either e a
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 :: (MonadIO m, Exception e) => e -> m a
throwTo :: (MonadIO m, Exception e) => ThreadId -> e -> m ()
throwSTM :: Exception e => e -> STM a
throwError :: MonadError e m => e -> m a

Utilities

hush :: Alternative m => Either e a -> m a
note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a
tryIO :: MonadIO m => IO a -> ExceptT IOException m a

Fatal Errors

data FatalError = FatalError {msg :: Text}
panic :: Text -> a