MIT licensed by Patrick Brisbin
Maintained by [email protected]
This version can be pinned in stack with:bugsnag-1.1.0.1@sha256:ce3c2b97a3b28c850b9dd2bb8c1c13636f054e66f535ef7b4ceb7369d108e136,4565

Bugsnag error reporter for Haskell

Hackage Stackage Nightly Stackage LTS

Catch exceptions in your Haskell code and report then to Bugsnag.

Configuration

let settings = defaultSettings "A_BUGSNAG_API_KEY"

Manual Reporting

Data.Bugsnag.Exception is the type of actual exceptions included in the event reported to Bugsnag. Constructing it directly can be useful to attach the current source location as a stack frame.

let
  ex = defaultException
    { exception_errorClass = "Error"
    , exception_message = Just "message"
    , exception_stacktrace = [$(currentStackFrame) "myFunction"]
    }

In order to treat it like an actual Haskell Exception (including to report it), wrap it in AsException:

notifyBugsnag settings $ AsException ex

Catching & Throwing

Catch any exceptions, notify, and re-throw:

myFunction `withException` notifyBugsnag @SomeException settings

Throw a manually-built exception:

throwIO $ AsException ex

Examples

Examples can be built locally with:

stack build --flag bugsnag:examples

bugsnag-hs

We depend on bugsnag-hs to define the types for the full reporting API payload. Unfortunately, it exposes them from its own Network.Bugsnag module, which conflicts with ourselves.

To get around this, we re-export that whole module as Data.Bugsnag. If you are currently depending on bugsnag-hs and wish to use our package too, we recommend you only depend on us and use its types through the Data.Bugsnag re-export.


CHANGELOG | LICENSE

Changes

Unreleased

v1.1.0.1

  • Strip trailing newlines when constructing Bugsnag.Exception messages from displayException values.

v1.1.0.0

  • New module: Network.Bugsnag.MetaData

  • Adds some support for the annotated-exception package. updateEventFromOriginalException now catches either e or AnnotatedException e.

    • bugsnagExceptionFromSomeException now has special cases to handle AnnotatedException well.
    • Annotations of type CallStack and MetaData are included in the bugsnag report; other annotations are ignored.
  • Adds explicit support for StringException from the unliftio package.

    • bugsnagExceptionFromSomeException now has special cases to handle StringException well.

v1.0.0.1

  • Support GHCs 9.0 and 9.2

v1.0.0.0

First released version.


For CHANGELOG details prior to the package re-organization, see archive/CHANGELOG.md.