cleveland-0.2.0: Testing framework for Morley.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Cleveland.Internal.Exceptions

Description

This module defines common exception types and exception-related functions used throughout the Test.Cleveland modules.

Synopsis

Documentation

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 type e wrapped in WithCallStack), it will be returned in a Left.
  • 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.