| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Haxl.Core.Exception
Contents
Description
An exception hierarchy that can be used with the Haxl monad.
The Haxl framework may throw exceptions from this hierarchy: for
example, a misbehaving data source causes dataFetch to throw a
DataSourceError. The combinator withDefault from
Haxl.Core.Prelude uses this hierarchy to provide default values
for expressions that raise TransientError or LogicError
exceptions.
You are under no obligations to use this hierarchy for your own
exceptions, but you might find it useful nonetheless; for
withDefault to be useful, for example, you'll want your
exceptions to be children of LogicError or TransientError as
appropriate.
Most users should import Haxl.Core instead of importing this module directly.
- data HaxlException = forall e . (Exception e, MiddleException e) => HaxlException e
- data InternalError = forall e . Exception e => InternalError e
- internalErrorToException :: Exception e => e -> SomeException
- internalErrorFromException :: Exception e => SomeException -> Maybe e
- data LogicError = forall e . Exception e => LogicError e
- logicErrorToException :: Exception e => e -> SomeException
- logicErrorFromException :: Exception e => SomeException -> Maybe e
- data TransientError = forall e . Exception e => TransientError e
- transientErrorToException :: Exception e => e -> SomeException
- transientErrorFromException :: Exception e => SomeException -> Maybe e
- data CriticalError = CriticalError Text
- data DataSourceError = DataSourceError Text
- data NotFound = NotFound Text
- data UnexpectedType = UnexpectedType Text
- data EmptyList = EmptyList Text
- data JSONError = JSONError Text
- data InvalidParameter = InvalidParameter Text
- data FetchError = FetchError Text
- asHaxlException :: SomeException -> HaxlException
Documentation
data HaxlException Source
We have a 3-tiered hierarchy of exceptions, with HaxlException at
the top, and all Haxl exceptions as children of this. Users should
never deal directly with HaxlExceptions.
The main types of exceptions are:
InternalError- Something is wrong with Haxl core.
LogicError- Something is wrong with Haxl client code.
TransientError- Something is temporarily failing (usually in a fetch).
These are not meant to be thrown (but likely be caught). Thrown
exceptions should be a subclass of one of these. There are some
generic leaf exceptions defined below this, such as FetchError
(generic transient failure) or CriticalError (internal failure).
Constructors
| forall e . (Exception e, MiddleException e) => HaxlException e |
Instances
| Show HaxlException Source | |
| ToJSON HaxlException Source | These need to be serializable to JSON to cross FFI boundaries. |
| Exception HaxlException Source |
Exception categories
data InternalError Source
For errors in Haxl core code.
Constructors
| forall e . Exception e => InternalError e |
Instances
internalErrorToException :: Exception e => e -> SomeException Source
internalErrorFromException :: Exception e => SomeException -> Maybe e Source
data LogicError Source
For errors in Haxl client code.
Constructors
| forall e . Exception e => LogicError e |
Instances
logicErrorToException :: Exception e => e -> SomeException Source
logicErrorFromException :: Exception e => SomeException -> Maybe e Source
data TransientError Source
For transient failures.
Constructors
| forall e . Exception e => TransientError e |
Instances
transientErrorToException :: Exception e => e -> SomeException Source
transientErrorFromException :: Exception e => SomeException -> Maybe e Source
Internal exceptions
data CriticalError Source
Generic "critical" exception. Something internal is borked. Panic.
Constructors
| CriticalError Text |
Logic exceptions
Generic "something was not found" exception.
data UnexpectedType Source
Generic "something had the wrong type" exception.
Constructors
| UnexpectedType Text |
Generic "input list was empty" exception.
Generic "Incorrect assumptions about JSON data" exception.
data InvalidParameter Source
Generic "passing some invalid parameter" exception.
Constructors
| InvalidParameter Text |
Transient exceptions
Exception utilities
asHaxlException :: SomeException -> HaxlException Source
Converts all exceptions that are not derived from HaxlException
into CriticalError, using show.