haxl-2.4.0.0: A Haskell library for efficient, concurrent, and concise data access.
Safe HaskellNone
LanguageHaskell2010

Haxl.Core.Exception

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.

Synopsis

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.
LogicBug
Something is wrong with Haxl client code.
LogicError
Things that really should be return values, e.g. NotFound.
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.MiddleException e => HaxlException (Maybe Stack) e 

Instances

Instances details
Show HaxlException Source # 
Instance details

Defined in Haxl.Core.Exception

ToJSON HaxlException Source #

These need to be serializable to JSON to cross FFI boundaries.

Instance details

Defined in Haxl.Core.Exception

Exception HaxlException Source # 
Instance details

Defined in Haxl.Core.Exception

Exception categories

data InternalError Source #

For errors in Haxl core code.

Constructors

forall e.Exception e => InternalError e 

data LogicError Source #

For errors in Haxl client code.

Constructors

forall e.Exception e => LogicError e 

data LogicBug Source #

Constructors

forall e.Exception e => LogicBug e 

Instances

Instances details
Show LogicBug Source # 
Instance details

Defined in Haxl.Core.Exception

Exception LogicBug Source # 
Instance details

Defined in Haxl.Core.Exception

MiddleException LogicBug Source # 
Instance details

Defined in Haxl.Core.Exception

Internal exceptions

newtype CriticalError Source #

Generic "critical" exception. Something internal is borked. Panic.

Constructors

CriticalError Text 

newtype NonHaxlException Source #

Exceptions that are converted to HaxlException by asHaxlException. Typically these will be pure exceptions, e.g., the error function in pure code, or a pattern-match failure.

Constructors

NonHaxlException Text 

Logic exceptions

newtype NotFound Source #

Generic "something was not found" exception.

Constructors

NotFound Text 

Instances

Instances details
Eq NotFound Source # 
Instance details

Defined in Haxl.Core.Exception

Show NotFound Source # 
Instance details

Defined in Haxl.Core.Exception

Exception NotFound Source # 
Instance details

Defined in Haxl.Core.Exception

Binary NotFound Source # 
Instance details

Defined in Haxl.Core.Exception

Methods

put :: NotFound -> Put #

get :: Get NotFound #

putList :: [NotFound] -> Put #

newtype UnexpectedType Source #

Generic "something had the wrong type" exception.

Constructors

UnexpectedType Text 

newtype EmptyList Source #

Generic "input list was empty" exception.

Constructors

EmptyList Text 

Instances

Instances details
Eq EmptyList Source # 
Instance details

Defined in Haxl.Core.Exception

Show EmptyList Source # 
Instance details

Defined in Haxl.Core.Exception

Exception EmptyList Source # 
Instance details

Defined in Haxl.Core.Exception

newtype JSONError Source #

Generic "Incorrect assumptions about JSON data" exception.

Constructors

JSONError Text 

Instances

Instances details
Eq JSONError Source # 
Instance details

Defined in Haxl.Core.Exception

Show JSONError Source # 
Instance details

Defined in Haxl.Core.Exception

Exception JSONError Source # 
Instance details

Defined in Haxl.Core.Exception

newtype MonadFail Source #

Generic "fail was called" exception.

Constructors

MonadFail Text 

Instances

Instances details
Eq MonadFail Source # 
Instance details

Defined in Haxl.Core.Exception

Show MonadFail Source # 
Instance details

Defined in Haxl.Core.Exception

Exception MonadFail Source # 
Instance details

Defined in Haxl.Core.Exception

Transient exceptions

newtype FetchError Source #

Generic transient fetching exceptions.

Constructors

FetchError Text 

Exception utilities

asHaxlException :: SomeException -> HaxlException Source #

Converts all exceptions that are not derived from HaxlException into NonHaxlException, using show.

class Exception a => MiddleException a where Source #

Methods

eName :: a -> String Source #

Instances

Instances details
MiddleException LogicBug Source # 
Instance details

Defined in Haxl.Core.Exception

MiddleException LogicError Source # 
Instance details

Defined in Haxl.Core.Exception

MiddleException InternalError Source # 
Instance details

Defined in Haxl.Core.Exception

MiddleException TransientError Source # 
Instance details

Defined in Haxl.Core.Exception