bugsnag-1.0.0.1: Bugsnag error reporter for Haskell
Safe HaskellNone
LanguageHaskell2010

Network.Bugsnag.BeforeNotify

Synopsis

Documentation

data BeforeNotify Source #

A function from Event to Event that is applied before notifying

The wrapped function also accepts the original exception, for cases in which that's useful -- but it's often not. Most BeforeNotifys use updateEvent, which discards it.

BeforeNotify implements Semigroup and Monoid, which means the /do nothing/ BeforeNotify is mempty and two BeforeNotifys doThis then doThat can be implemented as doThat <> doThis.

beforeNotify :: (forall e. Exception e => e -> Event -> Event) -> BeforeNotify Source #

Modifying the underlying Exceptions

Modifying the Event

updateEventFromOriginalException :: forall e. Exception e => (e -> BeforeNotify) -> BeforeNotify Source #

Update the Event based on the original exception

This allows updating the Event after casting to an exception type that this library doesn't know about (e.g. SqlError). Because the result of your function is itself a BeforeNotify, you can (and should) use other helpers:

myBeforeNotify =
    defaultBeforeNotify
        <> updateEventFromOriginalException asSqlError
        <> updateEventFromOriginalException asHttpError
        <> -- ...

asSqlError :: SqlError -> BeforeNotify
asSqlError SqlError{..} =
    setGroupingHash sqlErrorCode <> updateException (e -> e
        { exception_errorClass = sqlErrorCode
        , exception_message = Just sqlErrorMessage
        })

If the cast fails, the event is unchanged.

setDevice :: Device -> BeforeNotify Source #

Set the Event's Device

See bugsnagDeviceFromWaiRequest

setContext :: Text -> BeforeNotify Source #

Set the Event's Context

setRequest :: Request -> BeforeNotify Source #

Set the Event's Request

See bugsnagRequestFromWaiRequest

setWarningSeverity :: BeforeNotify Source #

Set to WarningSeverity

setErrorSeverity :: BeforeNotify Source #

Set to ErrorSeverity

setInfoSeverity :: BeforeNotify Source #

Set to InfoSeverity