Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines common exception types and exception-related functions used throughout the Test.Cleveland modules.
Synopsis
- data WithCallStack where
- WithCallStack :: CallStack -> SomeException -> WithCallStack
- addCallStack :: forall m a. (HasCallStack, MonadCatch m) => m a -> m a
- throwWithCallStack :: forall e a m. (MonadThrow m, Exception e) => CallStack -> e -> m a
- tryWithCallStack :: forall e a m. (MonadCatch m, Exception e) => m a -> m (Either (Maybe CallStack, e) a)
- catchWithCallStack :: forall e a m. (Exception e, MonadCatch m) => m a -> (Maybe CallStack -> e -> m a) -> m a
Documentation
data WithCallStack where Source #
Wraps an exception and adds some callstack information.
WithCallStack :: CallStack -> SomeException -> WithCallStack |
Instances
Exception WithCallStack Source # | |
Defined in Test.Cleveland.Internal.Exceptions | |
Show WithCallStack Source # | |
Defined in Test.Cleveland.Internal.Exceptions showsPrec :: Int -> WithCallStack -> ShowS # show :: WithCallStack -> String # showList :: [WithCallStack] -> ShowS # | |
Buildable WithCallStack Source # | |
Defined in Test.Cleveland.Internal.Exceptions build :: WithCallStack -> Builder # |
addCallStack :: forall m a. (HasCallStack, MonadCatch m) => m a -> m a Source #
Wrap any exceptions thrown by some monadic action with WithCallStack
.
If the action throws an exception already wrapped in WithCallStack
,
that callstack will be overriden with the current one.
throwWithCallStack :: forall e a m. (MonadThrow m, Exception e) => CallStack -> e -> m a Source #
tryWithCallStack :: forall e a m. (MonadCatch m, Exception e) => m a -> m (Either (Maybe CallStack, e) a) Source #
Attempts to run the given action.
If it:
- suceeds, the value will be returned in a
Right
. - throws an exception of the given type
e
(or an exception of typee
wrapped inWithCallStack
), it will be returned in aLeft
. - throws an exception of any other type, it'll be rethrown (retaining the original callstack, if any).
catchWithCallStack :: forall e a m. (Exception e, MonadCatch m) => m a -> (Maybe CallStack -> e -> m a) -> m a Source #
Similar to catch
, but also catches exceptions of type e
wrapped in WithCallStack
.