| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Exception.Utils
Description
This is essentially an addition to the exceptions API. Note we do
not export that API. This is merely some useful additional utilities.
Since: 0.1
Synopsis
- newtype StringException = MkStringException String
- throwText :: (HasCallStack, MonadThrow m) => Text -> m a
- throwString :: (HasCallStack, MonadThrow m) => String -> m a
- catchDeep :: forall m e a. (Exception e, HasCallStack, MonadCatch m, MonadIO m, NFData a) => m a -> (e -> m a) -> m a
- catchDeepSync :: (HasCallStack, MonadCatch m, MonadIO m, NFData a) => m a -> (SomeException -> m a) -> m a
- catchSync :: (HasCallStack, MonadCatch m) => m a -> (SomeException -> m a) -> m a
- catchIf :: forall m e a. (Exception e, HasCallStack, MonadCatch m) => (e -> Bool) -> m a -> (e -> m a) -> m a
- catchesSync :: forall m f a. (Foldable f, HasCallStack, MonadCatch m) => m a -> (SomeException -> m a) -> f (Handler m a) -> m a
- handleDeep :: forall m e a. (Exception e, MonadCatch m, MonadIO m, NFData a) => (e -> m a) -> m a -> m a
- handleDeepSync :: (MonadCatch m, MonadIO m, NFData a) => (SomeException -> m a) -> m a -> m a
- handleSync :: (HasCallStack, MonadCatch m) => (SomeException -> m a) -> m a -> m a
- handleIf :: forall m e a. (Exception e, HasCallStack, MonadCatch m) => (e -> Bool) -> (e -> m a) -> m a -> m a
- tryDeep :: forall m e a. (Exception e, MonadCatch m, MonadIO m, NFData a) => m a -> m (Either e a)
- tryDeepSync :: (MonadCatch m, MonadIO m, NFData a) => m a -> m (Either SomeException a)
- trySync :: (HasCallStack, MonadCatch m) => m a -> m (Either SomeException a)
- tryIf :: forall m e a. (Exception e, HasCallStack, MonadCatch m) => (e -> Bool) -> m a -> m (Either e a)
- onSyncException :: (HasCallStack, MonadCatch m) => m a -> m b -> m a
- onAsyncException :: (HasCallStack, MonadCatch m) => m a -> m b -> m a
- exitFailure :: (HasCallStack, MonadThrow m) => m a
- exitSuccess :: (HasCallStack, MonadThrow m) => m a
- exitWith :: (HasCallStack, MonadThrow m) => ExitCode -> m a
- mkHandlerSync :: (HasCallStack, MonadThrow m) => (SomeException -> m a) -> Handler m a
- isSyncException :: Exception e => e -> Bool
- isAsyncException :: Exception e => e -> Bool
Throwing
String exception
newtype StringException Source #
Exception that contains a string description.
Since: 0.1
Constructors
| MkStringException String |
Instances
| Exception StringException Source # | |
Defined in Control.Exception.Utils Methods toException :: StringException -> SomeException # fromException :: SomeException -> Maybe StringException # displayException :: StringException -> String # backtraceDesired :: StringException -> Bool # | |
| Show StringException Source # | |
Defined in Control.Exception.Utils Methods showsPrec :: Int -> StringException -> ShowS # show :: StringException -> String # showList :: [StringException] -> ShowS # | |
| Eq StringException Source # | |
Defined in Control.Exception.Utils Methods (==) :: StringException -> StringException -> Bool # (/=) :: StringException -> StringException -> Bool # | |
throwText :: (HasCallStack, MonadThrow m) => Text -> m a Source #
Throws an exception with the Text description.
Since: 0.1
throwString :: (HasCallStack, MonadThrow m) => String -> m a Source #
Throws an exception with the String description.
Since: 0.1
Catching
Arguments
| :: forall m e a. (Exception e, HasCallStack, MonadCatch m, MonadIO m, NFData a) | |
| => m a | |
| -> (e -> m a) | The exception handler. |
| -> m a |
Like catch, except it fully evaluates the result to find impure
exceptions.
Since: 0.1
Arguments
| :: (HasCallStack, MonadCatch m, MonadIO m, NFData a) | |
| => m a | |
| -> (SomeException -> m a) | The exception handler. |
| -> m a |
catchDeep specialized to synchronous SomeException.
Since: 0.1
Arguments
| :: (HasCallStack, MonadCatch m) | |
| => m a | |
| -> (SomeException -> m a) | The exception handler. |
| -> m a |
catch specialized to catch all synchronous SomeExceptions.
Since: 0.1
Arguments
| :: forall m e a. (Exception e, HasCallStack, MonadCatch m) | |
| => (e -> Bool) | The predicate. |
| -> m a | |
| -> (e -> m a) | The exception handler. |
| -> m a |
Catch an exception only if it satisfies a specific predicate.
Since: 0.1
Arguments
| :: forall m f a. (Foldable f, HasCallStack, MonadCatch m) | |
| => m a | Action. |
| -> (SomeException -> m a) | Handler for synchronous |
| -> f (Handler m a) | Other handlers. |
| -> m a |
Like catches, except it includes a handler for SomeException that
does not catch async exceptions.
Since: 0.1
Arguments
| :: forall m e a. (Exception e, MonadCatch m, MonadIO m, NFData a) | |
| => (e -> m a) | The exception handler. |
| -> m a | |
| -> m a |
Flipped catchDeep.
Since: 0.1
Arguments
| :: (MonadCatch m, MonadIO m, NFData a) | |
| => (SomeException -> m a) | The exception handler. |
| -> m a | |
| -> m a |
Flipped catchDeepSync.
Since: 0.1
handleSync :: (HasCallStack, MonadCatch m) => (SomeException -> m a) -> m a -> m a Source #
Flipped catchSync.
Since: 0.1
Arguments
| :: forall m e a. (Exception e, HasCallStack, MonadCatch m) | |
| => (e -> Bool) | The predicate. |
| -> (e -> m a) | The exception handler. |
| -> m a | |
| -> m a |
Flipped catchIf.
Since: 0.1
Arguments
| :: forall m e a. (Exception e, MonadCatch m, MonadIO m, NFData a) | |
| => m a | The action. |
| -> m (Either e a) |
Like try, except it fully evaluates the result to find impure
exceptions.
Since: 0.1
Arguments
| :: (MonadCatch m, MonadIO m, NFData a) | |
| => m a | The action. |
| -> m (Either SomeException a) |
tryDeep specialized to synchronous SomeException.
Since: 0.1
trySync :: (HasCallStack, MonadCatch m) => m a -> m (Either SomeException a) Source #
try specialized to catch all synchronous SomeExceptions.
Since: 0.1
Arguments
| :: forall m e a. (Exception e, HasCallStack, MonadCatch m) | |
| => (e -> Bool) | The predicate. |
| -> m a | |
| -> m (Either e a) |
Catch an exception only if it satisfies a specific predicate.
Since: 0.1
Cleanup
onSyncException :: (HasCallStack, MonadCatch m) => m a -> m b -> m a Source #
Like onException, except it does not catch asynchronous exception.
Since: 0.1
Arguments
| :: (HasCallStack, MonadCatch m) | |
| => m a | Action to run. |
| -> m b | Exception handler. |
| -> m a |
Like onException, except it _only_ catches asynchronous exceptions
before rethrowing. Note that the handler swallows _all_ exceptions, since
we want the original to be rethrown.
Since: 0.1
Exiting
exitFailure :: (HasCallStack, MonadThrow m) => m a Source #
The computation exitFailure is equivalent to
exitWith (ExitFailure exitfail),
where exitfail is implementation-dependent.
Since: 0.1
exitSuccess :: (HasCallStack, MonadThrow m) => m a Source #
The computation exitSuccess is equivalent to
exitWith ExitSuccess, It terminates the program
successfully.
Since: 0.1
exitWith :: (HasCallStack, MonadThrow m) => ExitCode -> m a Source #
Lifted exitWith.
Since: 0.1
Misc
mkHandlerSync :: (HasCallStack, MonadThrow m) => (SomeException -> m a) -> Handler m a Source #
Creates a handler for synchronous exceptions.
Since: 0.1
isSyncException :: Exception e => e -> Bool Source #
Returns True iff the exception is not a subtype of
SomeAsyncException.
Since: 0.1
isAsyncException :: Exception e => e -> Bool Source #
Negation of isSyncException.
Since: 0.1