-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Provides API for enriching errors with contexts -- -- Please see the README on Github at -- https://github.com/mtesseract/error-context#readme @package error-context @version 0.2.0.1 -- | Provides an API for enriching errors with contexts. module Control.Error.Context.Types data ErrorContext ErrorContext :: HashMap Text Value -> [Text] -> ErrorContext [errorContextKVs] :: ErrorContext -> HashMap Text Value [errorContextNamespace] :: ErrorContext -> [Text] -- | Boundles an error with an ErrorContext. data ErrorWithContext e ErrorWithContext :: ErrorContext -> e -> ErrorWithContext e errorContextAsString :: ErrorContext -> String -- | Monad type class providing contextualized errors. class (Monad m, MonadThrow m) => MonadErrorContext m errorContextCollect :: MonadErrorContext m => m ErrorContext withErrorContext :: (MonadErrorContext m, ToJSON v) => Text -> v -> m a -> m a withErrorNamespace :: MonadErrorContext m => Text -> m a -> m a instance GHC.Show.Show e => GHC.Show.Show (Control.Error.Context.Types.ErrorWithContext e) instance GHC.Base.Functor Control.Error.Context.Types.ErrorWithContext instance GHC.Exception.Exception e => GHC.Exception.Exception (Control.Error.Context.Types.ErrorWithContext e) instance GHC.Base.Monoid Control.Error.Context.Types.ErrorContext module Control.Error.Context.Exception -- | Like catch, but the handler is required to be context-aware. Is -- also able to catch exceptions of type e (without context). catchWithContext :: (MonadCatch m, Exception e) => m a -> (ErrorWithContext e -> m a) -> m a -- | Like catch, but the handler is required to be context-unaware. -- Is also able to catch exceptions with context, in which case the -- context will be forgotten before the exception will be provided to the -- handler. catchWithoutContext :: forall a e m. (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a tryAnyWithContext :: MonadCatch m => m a -> m (Either (ErrorWithContext SomeException) a) tryAnyWithoutContext :: MonadCatch m => m a -> m (Either SomeException a) tryWithContext :: (MonadCatch m, Exception e) => m a -> m (Either (ErrorWithContext e) a) tryWithoutContext :: (MonadCatch m, Exception e) => m a -> m (Either e a) -- | Forgets the context from an enriched error. errorContextForget :: ErrorWithContext e -> e -- | Context aware version of catchAny. catchAnyWithContext :: MonadCatch m => m a -> (ErrorWithContext SomeException -> m a) -> m a -- | Context aware version of catchAny. catchAnyWithoutContext :: MonadCatch m => m a -> (SomeException -> m a) -> m a module Control.Error.Context.Simple -- | Data type implementing MonadErrorContext. newtype ErrorContextT m a ErrorContextT :: ReaderT ErrorContext m a -> ErrorContextT m a [_runErrorContextT] :: ErrorContextT m a -> ReaderT ErrorContext m a runErrorContextT :: ErrorContextT m a -> m a instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.Trans.Class.MonadTrans Control.Error.Context.Simple.ErrorContextT instance GHC.Base.Monad m => GHC.Base.Monad (Control.Error.Context.Simple.ErrorContextT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Error.Context.Simple.ErrorContextT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Error.Context.Simple.ErrorContextT m) instance (Control.Monad.Catch.MonadCatch m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadThrow (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.Catch.MonadCatch m => Control.Error.Context.Types.MonadErrorContext (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Error.Context.Simple.ErrorContextT m) instance (Control.Monad.Catch.MonadCatch m, Control.Monad.Trans.Resource.Internal.MonadResource m) => Control.Monad.Trans.Resource.Internal.MonadResource (Control.Error.Context.Simple.ErrorContextT m) instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Error.Context.Simple.ErrorContextT m) -- | Provides an API for enriching errors with contexts. module Control.Error.Context.Katip -- | Data type implementing MonadErrorContext. newtype ErrorContextKatipT m a ErrorContextKatipT :: m a -> ErrorContextKatipT m a [runErrorContextKatipT] :: ErrorContextKatipT m a -> m a instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Error.Context.Katip.ErrorContextKatipT m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Error.Context.Katip.ErrorContextKatipT m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Error.Context.Katip.ErrorContextKatipT m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Error.Context.Katip.ErrorContextKatipT m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Error.Context.Katip.ErrorContextKatipT m) instance Control.Monad.Trans.Class.MonadTrans Control.Error.Context.Katip.ErrorContextKatipT instance (Control.Monad.Catch.MonadCatch m, Katip.Monadic.KatipContext m, Control.Monad.IO.Class.MonadIO m, Katip.Core.Katip m) => Katip.Core.Katip (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Control.Monad.Catch.MonadCatch m, Katip.Monadic.KatipContext m) => Katip.Monadic.KatipContext (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Katip.Monadic.KatipContext m, Control.Monad.Catch.MonadCatch m, Control.Monad.IO.Class.MonadIO m) => Control.Monad.IO.Class.MonadIO (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Katip.Monadic.KatipContext m, Control.Monad.Catch.MonadCatch m) => Control.Monad.Catch.MonadThrow (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Control.Monad.Catch.MonadCatch m, Katip.Monadic.KatipContext m) => Control.Error.Context.Types.MonadErrorContext (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Katip.Monadic.KatipContext m, Control.Monad.Catch.MonadCatch m) => Control.Monad.Catch.MonadCatch (Control.Error.Context.Katip.ErrorContextKatipT m) instance (Katip.Monadic.KatipContext m, Control.Monad.Catch.MonadCatch m, Control.Monad.Trans.Resource.Internal.MonadResource m) => Control.Monad.Trans.Resource.Internal.MonadResource (Control.Error.Context.Katip.ErrorContextKatipT m) instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Error.Context.Katip.ErrorContextKatipT m) -- | Provides an API for enriching errors with contexts. module Control.Error.Context -- | Monad type class providing contextualized errors. class (Monad m, MonadThrow m) => MonadErrorContext m errorContextCollect :: MonadErrorContext m => m ErrorContext withErrorContext :: (MonadErrorContext m, ToJSON v) => Text -> v -> m a -> m a withErrorNamespace :: MonadErrorContext m => Text -> m a -> m a data ErrorContext ErrorContext :: HashMap Text Value -> [Text] -> ErrorContext [errorContextKVs] :: ErrorContext -> HashMap Text Value [errorContextNamespace] :: ErrorContext -> [Text] -- | Data type implementing MonadErrorContext. data ErrorContextT m a runErrorContextT :: ErrorContextT m a -> m a -- | Data type implementing MonadErrorContext. newtype ErrorContextKatipT m a ErrorContextKatipT :: m a -> ErrorContextKatipT m a [runErrorContextKatipT] :: ErrorContextKatipT m a -> m a -- | Boundles an error with an ErrorContext. data ErrorWithContext e ErrorWithContext :: ErrorContext -> e -> ErrorWithContext e -- | Enrich an error value with an error context. errorContextualize :: MonadErrorContext m => e -> m (ErrorWithContext e) -- | Forgets the context from an enriched error. errorContextForget :: ErrorWithContext e -> e -- | Dump an error with context to stdout. errorWithContextDump :: (Show e, MonadIO m) => ErrorWithContext e -> m () -- | Like catch, but the handler is required to be context-unaware. -- Is also able to catch exceptions with context, in which case the -- context will be forgotten before the exception will be provided to the -- handler. catchWithoutContext :: forall a e m. (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a -- | Like catch, but the handler is required to be context-aware. Is -- also able to catch exceptions of type e (without context). catchWithContext :: (MonadCatch m, Exception e) => m a -> (ErrorWithContext e -> m a) -> m a -- | Context aware version of catchAny. catchAnyWithContext :: MonadCatch m => m a -> (ErrorWithContext SomeException -> m a) -> m a -- | Context aware version of catchAny. catchAnyWithoutContext :: MonadCatch m => m a -> (SomeException -> m a) -> m a ensureExceptionContext :: (MonadCatch m, MonadErrorContext m) => m a -> m a tryAnyWithContext :: MonadCatch m => m a -> m (Either (ErrorWithContext SomeException) a) tryAnyWithoutContext :: MonadCatch m => m a -> m (Either SomeException a) tryWithContext :: (MonadCatch m, Exception e) => m a -> m (Either (ErrorWithContext e) a) tryWithoutContext :: (MonadCatch m, Exception e) => m a -> m (Either e a)