partial-handler-1.0.0.0: A composable exception handler

Safe HaskellSafe-Inferred
LanguageHaskell2010

PartialHandler

Contents

Synopsis

Documentation

newtype PartialHandler a Source

A composable exception handler.

Constructors

PartialHandler (SomeException -> Maybe (IO a)) 

Instances

Totalizers

type TotalHandler a = SomeException -> IO a Source

A function, which handles all exceptions.

Can be used as a parameter to standard functions like catch and handle, or to process the result of try.

totalize :: PartialHandler a -> TotalHandler a Source

Convert a partial handler into a total handler, which throws an error for unhandled cases. In other words, the produced total handler is itself a partial function, so use this only in cases when an unhandled exception should be considered as a bug.

totalizeRethrowing :: PartialHandler a -> TotalHandler a Source

Convert a partial handler into a total handler, which rethrows all unhandled exceptions.

totalizeRethrowingTo :: ThreadId -> PartialHandler a -> TotalHandler a Source

Convert a partial handler into a total handler, which rethrows all unhandled exceptions to the specified thread and the current thread.

totalizeRethrowingTo_ :: ThreadId -> PartialHandler () -> TotalHandler () Source

Convert a partial handler into a total handler, which rethrows all unhandled exceptions to the specified thread, while the current thread continues the execution.

Standard handlers

typed :: Exception e => (e -> Maybe (IO a)) -> PartialHandler a Source

A handler of exceptions of a specific type.

AsyncException handlers

onThreadKilled :: IO a -> PartialHandler a Source

A handler of the ThreadKilled exception.

IOError handlers

onIOErrorByType :: (IOErrorType -> Maybe (IO a)) -> PartialHandler a Source

A handler of all exceptions of type IOError by their type.

onAlreadyExists :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isAlreadyExistsError predicate.

onDoesNotExist :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isDoesNotExistError predicate.

onAlreadyInUse :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isAlreadyInUseError predicate.

onFull :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isFullError predicate.

onEOF :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isEOFError predicate.

onIllegalOperation :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isIllegalOperation predicate.

onPermission :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isPermissionError predicate.

onUser :: IO a -> PartialHandler a Source

A handler of an IOError exception with type satisfying the isUserError predicate.