| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.Bugsnag.BeforeNotify
Synopsis
- data BeforeNotify
- beforeNotify :: (forall e. Exception e => e -> Event -> Event) -> BeforeNotify
- runBeforeNotify :: Exception e => BeforeNotify -> e -> Event -> Event
- updateExceptions :: (Exception -> Exception) -> BeforeNotify
- filterExceptions :: (Exception -> Bool) -> BeforeNotify
- updateStackFrames :: (StackFrame -> StackFrame) -> BeforeNotify
- filterStackFrames :: (StackFrame -> Bool) -> BeforeNotify
- setStackFramesCode :: CodeIndex -> BeforeNotify
- setStackFramesInProject :: Bool -> BeforeNotify
- setStackFramesInProjectByFile :: (FilePath -> Bool) -> BeforeNotify
- setStackFramesInProjectBy :: (StackFrame -> Bool) -> BeforeNotify
- updateEvent :: (Event -> Event) -> BeforeNotify
- updateEventFromOriginalException :: Exception e => (e -> BeforeNotify) -> BeforeNotify
- setGroupingHash :: Text -> BeforeNotify
- setGroupingHashBy :: (Event -> Maybe Text) -> BeforeNotify
- setDevice :: Device -> BeforeNotify
- setContext :: Text -> BeforeNotify
- setRequest :: Request -> BeforeNotify
- setWarningSeverity :: BeforeNotify
- setErrorSeverity :: BeforeNotify
- setInfoSeverity :: BeforeNotify
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.
Instances
| Monoid BeforeNotify Source # | |
Defined in Network.Bugsnag.BeforeNotify Methods mempty :: BeforeNotify # mappend :: BeforeNotify -> BeforeNotify -> BeforeNotify # mconcat :: [BeforeNotify] -> BeforeNotify # | |
| Semigroup BeforeNotify Source # | |
Defined in Network.Bugsnag.BeforeNotify Methods (<>) :: BeforeNotify -> BeforeNotify -> BeforeNotify # sconcat :: NonEmpty BeforeNotify -> BeforeNotify # stimes :: Integral b => b -> BeforeNotify -> BeforeNotify # | |
beforeNotify :: (forall e. Exception e => e -> Event -> Event) -> BeforeNotify Source #
runBeforeNotify :: Exception e => BeforeNotify -> e -> Event -> Event Source #
Modifying the underlying Exceptions
updateExceptions :: (Exception -> Exception) -> BeforeNotify Source #
filterExceptions :: (Exception -> Bool) -> BeforeNotify Source #
updateStackFrames :: (StackFrame -> StackFrame) -> BeforeNotify Source #
filterStackFrames :: (StackFrame -> Bool) -> BeforeNotify Source #
setStackFramesInProjectByFile :: (FilePath -> Bool) -> BeforeNotify Source #
setStackFramesInProjectBy :: (StackFrame -> Bool) -> BeforeNotify Source #
Modifying the Event
updateEvent :: (Event -> Event) -> BeforeNotify Source #
updateEventFromOriginalException :: 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.
The cast will match either e or .AnnotatedException e
setGroupingHash :: Text -> BeforeNotify Source #
setGroupingHashBy :: (Event -> Maybe Text) -> BeforeNotify Source #
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