| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Bio.Iteratee.Exception
Description
Monadic and General Iteratees: Messaging and exception handling.
Iteratees use an internal exception handling mechanism that is parallel to
that provided by Exception. This allows the iteratee framework
to handle its own exceptions outside IO.
Iteratee exceptions are divided into two categories, IterException and
EnumException. IterExceptions are exceptions within an iteratee, and
EnumExceptions are exceptions within an enumerator.
Enumerators can be constructed to handle an IterException with
Data.Iteratee.Iteratee.enumFromCallbackCatch. If the enumerator detects
an iteratee exception, the enumerator calls the provided exception handler.
The enumerator is then able to continue feeding data to the iteratee,
provided the exception was successfully handled. If the handler could
not handle the exception, the IterException is converted to an
EnumException and processing aborts.
Exceptions can also be cleared by Data.Iteratee.Iteratee.checkErr,
although in this case the iteratee continuation cannot be recovered.
When viewed as Resumable Exceptions, iteratee exceptions provide a means
for iteratees to send control messages to enumerators. The seek
implementation provides an example. Data.Iteratee.Iteratee.seek stores
the current iteratee continuation and throws a SeekException, which
inherits from IterException. Data.Iteratee.IO.enumHandleRandom is
constructed with enumFromCallbackCatch and a handler that performs
an hSeek. Upon receiving the SeekException, enumHandleRandom calls
the handler, checks that it executed properly, and then continues with
the stored continuation.
As the exception hierarchy is open, users can extend it with custom exceptions and exception handlers to implement sophisticated messaging systems based upon resumable exceptions.
- data IFException = forall e . Exception e => IFException e
- class (Typeable * e, Show e) => Exception e where
- toException :: e -> SomeException
- fromException :: SomeException -> Maybe e
- displayException :: e -> String
- data EnumException = forall e . Exception e => EnumException e
- data DivergentException = DivergentException
- data EnumStringException = EnumStringException String
- data EnumUnhandledIterException = EnumUnhandledIterException IterException
- class Exception e => IException e where
- toIterException :: e -> IterException
- fromIterException :: IterException -> Maybe e
- data IterException = forall e . Exception e => IterException e
- data SeekException = SeekException FileOffset
- data EofException = EofException
- data IterStringException = IterStringException String
- enStrExc :: String -> EnumException
- iterStrExc :: String -> SomeException
- wrapIterExc :: IterException -> EnumException
- iterExceptionToException :: Exception e => e -> SomeException
- iterExceptionFromException :: Exception e => SomeException -> Maybe e
Exception types
data IFException Source
Root of the Iteratee exception hierarchy. IFException derives from
Control.Exception.SomeException. EnumException, IterException,
and all inheritants are descendents of IFException.
Constructors
| forall e . Exception e => IFException e |
Instances
class (Typeable * e, Show e) => Exception e where
Minimal complete definition
Nothing
Methods
toException :: e -> SomeException
fromException :: SomeException -> Maybe e
displayException :: e -> String
Instances
| Exception ExitCode | |
| Exception NestedAtomically | |
| Exception NoMethodError | |
| Exception NonTermination | |
| Exception PatternMatchFail | |
| Exception RecConError | |
| Exception RecSelError | |
| Exception RecUpdError | |
| Exception ArithException | |
| Exception ErrorCall | |
| Exception AllocationLimitExceeded | |
| Exception ArrayException | |
| Exception AssertionFailed | |
| Exception AsyncException | |
| Exception BlockedIndefinitelyOnMVar | |
| Exception BlockedIndefinitelyOnSTM | |
| Exception Deadlock | |
| Exception SomeAsyncException | |
| Exception SomeException | |
| Exception IOException | |
| Exception DecompressError | |
| Exception IterStringException | |
| Exception EofException | |
| Exception SeekException | |
| Exception IterException | |
| Exception EnumUnhandledIterException | |
| Exception EnumStringException | |
| Exception DivergentException | |
| Exception EnumException | |
| Exception IFException | |
| Exception Void | |
| Exception UnicodeException | |
| Exception ParseError | |
| Exception ZLibException | |
| Exception ZLibParamsException |
Enumerator exceptions
data DivergentException Source
The iteratee diverged upon receiving EOF.
Constructors
| DivergentException |
Instances
data EnumStringException Source
Create an enumerator exception from a String.
Constructors
| EnumStringException String |
Instances
data EnumUnhandledIterException Source
The enumerator received an IterException it could not handle.
Constructors
| EnumUnhandledIterException IterException |
Iteratee exceptions
class Exception e => IException e where Source
A class for iteratee exceptions. Only inheritants of IterException
should be instances of this class.
Minimal complete definition
Nothing
Methods
toIterException :: e -> IterException Source
fromIterException :: IterException -> Maybe e Source
data IterException Source
Root of iteratee exceptions.
Constructors
| forall e . Exception e => IterException e |
Instances
data SeekException Source
A seek request within an Iteratee.
Constructors
| SeekException FileOffset |
Instances
data EofException Source
The Iteratee needs more data but received EOF.
Constructors
| EofException |
Instances
data IterStringException Source
An Iteratee exception specified by a String.
Constructors
| IterStringException String |
Functions
enStrExc :: String -> EnumException Source
Create an EnumException from a string.
iterStrExc :: String -> SomeException Source
Create an iteratee exception from a string.
This convenience function wraps IterStringException and toException.
wrapIterExc :: IterException -> EnumException Source
Convert an IterException to an EnumException. Meant to be used
within an Enumerator to signify that it could not handle the
IterException.
iterExceptionToException :: Exception e => e -> SomeException Source
iterExceptionFromException :: Exception e => SomeException -> Maybe e Source