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 TextException = MkTextException Text
- 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
- 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
- exitFailure :: (HasCallStack, MonadThrow m) => m a
- exitSuccess :: (HasCallStack, MonadThrow m) => m a
- exitWith :: (HasCallStack, MonadThrow m) => ExitCode -> m a
- isSyncException :: Exception e => e -> Bool
- isAsyncException :: Exception e => e -> Bool
Throwing
Text exception
newtype TextException Source #
Exception that contains a text description.
Since: 0.1
Constructors
MkTextException Text |
Instances
Exception TextException Source # | |
Defined in Control.Exception.Utils Methods toException :: TextException -> SomeException # fromException :: SomeException -> Maybe TextException # displayException :: TextException -> String # backtraceDesired :: TextException -> Bool # | |
Show TextException Source # | |
Defined in Control.Exception.Utils Methods showsPrec :: Int -> TextException -> ShowS # show :: TextException -> String # showList :: [TextException] -> ShowS # | |
Eq TextException Source # | |
Defined in Control.Exception.Utils Methods (==) :: TextException -> TextException -> Bool # (/=) :: TextException -> TextException -> 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 SomeException
s.
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.
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 SomeException
s.
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.
Cleanup
onSyncException :: (HasCallStack, MonadCatch m) => m a -> m b -> m a Source #
Like onException
, except it does not catch asynchronous exception.
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
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