base-4.20.2.0: Core data structures and operations

Copyright | (c) The University of Glasgow 1998-2002
License | see libraries/base/LICENSE
Maintainer | cvs-ghc@haskell.org
Stability | internal
Portability | non-portable (GHC extensions)
Safe Haskell | None
Language | Haskell2010

Control.Exception.Context

Contents

- Destructuring

Description

Exception context and annotations.

Synopsis

- data ExceptionContext = ExceptionContext [SomeExceptionAnnotation]
- emptyExceptionContext :: ExceptionContext
- addExceptionAnnotation :: ExceptionAnnotation a => a -> ExceptionContext -> ExceptionContext
- getExceptionAnnotations :: ExceptionAnnotation a => ExceptionContext -> [a]
- getAllExceptionAnnotations :: ExceptionContext -> [SomeExceptionAnnotation]
- displayExceptionContext :: ExceptionContext -> String

# Documentation

data ExceptionContext Source #

Exception context represents a list of `ExceptionAnnotation`s. These are attached to `SomeException`s via `addExceptionContext` and can be used to capture various ad-hoc metadata about the exception including backtraces and application-specific context.

`ExceptionContext`s can be merged via concatenation using the `Semigroup` instance or `mergeExceptionContext`.

Note that GHC will automatically solve implicit constraints of type `ExceptionContext` with `emptyExceptionContext`.

Constructors

ExceptionContext [SomeExceptionAnnotation] |

#### Instances

Instances details

Monoid ExceptionContext |
Instance details Defined in GHC.Internal.Exception.Context Methods mempty :: ExceptionContext Source # mappend :: ExceptionContext -> ExceptionContext -> ExceptionContext Source # mconcat :: [ExceptionContext] -> ExceptionContext Source #
Semigroup ExceptionContext |
Instance details Defined in GHC.Internal.Exception.Context Methods (<>) :: ExceptionContext -> ExceptionContext -> ExceptionContext Source # sconcat :: NonEmpty ExceptionContext -> ExceptionContext Source # stimes :: Integral b => b -> ExceptionContext -> ExceptionContext Source #

emptyExceptionContext :: ExceptionContext Source #

An `ExceptionContext` containing no annotations.

Since: base-4.20.0.0

addExceptionAnnotation :: ExceptionAnnotation a => a -> ExceptionContext -> ExceptionContext Source #

Construct a singleton `ExceptionContext` from an `ExceptionAnnotation`.

Since: base-4.20.0.0

# Destructuring

getExceptionAnnotations :: ExceptionAnnotation a => ExceptionContext -> [a] Source #

Retrieve all `ExceptionAnnotation`s of the given type from an `ExceptionContext`.

Since: base-4.20.0.0

getAllExceptionAnnotations :: ExceptionContext -> [SomeExceptionAnnotation] Source #

displayExceptionContext :: ExceptionContext -> String Source #

Render `ExceptionContext` to a human-readable `String`.

Since: base-4.20.0.0