| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.Bugsnag.BeforeNotify
Contents
Synopsis
- type BeforeNotify = BugsnagEvent -> BugsnagEvent
- updateException :: (BugsnagException -> BugsnagException) -> BeforeNotify
- updateStackFrames :: (BugsnagStackFrame -> BugsnagStackFrame) -> BeforeNotify
- filterStackFrames :: (BugsnagStackFrame -> Bool) -> BeforeNotify
- setStackFramesCode :: CodeIndex -> BeforeNotify
- setStackFramesInProject :: (FilePath -> Bool) -> BeforeNotify
- setStackFramesInProjectBy :: (BugsnagStackFrame -> a) -> (a -> Bool) -> BeforeNotify
- setGroupingHash :: Text -> BeforeNotify
- setGroupingHashBy :: (BugsnagEvent -> Maybe Text) -> BeforeNotify
- updateEventFromException :: (BugsnagException -> BeforeNotify) -> BeforeNotify
- updateEventFromOriginalException :: Exception e => (e -> BeforeNotify) -> BeforeNotify
- updateEventFromSession :: BugsnagSession -> BeforeNotify
- updateEventFromWaiRequest :: Request -> BeforeNotify
- updateEventFromWaiRequestUnredacted :: Request -> BeforeNotify
- redactRequestHeaders :: [HeaderName] -> BeforeNotify
- setDevice :: BugsnagDevice -> BeforeNotify
- setRequest :: BugsnagRequest -> BeforeNotify
- setStacktrace :: [BugsnagStackFrame] -> BeforeNotify
- setWarningSeverity :: BeforeNotify
- setErrorSeverity :: BeforeNotify
- setInfoSeverity :: BeforeNotify
Documentation
type BeforeNotify = BugsnagEvent -> BugsnagEvent #
Modifying the Exception
updateException :: (BugsnagException -> BugsnagException) -> BeforeNotify #
Modify just the Exception part of an Event
This may be used to set more specific information for exception types in scope in your application:
notifyBugsnagWith (updateException forSqlError) settings ex
forSqlError :: BugsnagException -> BugsnagException
forSqlError ex =
case fromException =<< beOriginalException ex of
Just SqlError{..} -> ex
{ beErrorClass = "SqlError-" <> sqlErrorCode
, beMessage = Just sqlErrorMessage
}
_ -> exupdateStackFrames :: (BugsnagStackFrame -> BugsnagStackFrame) -> BeforeNotify #
Apply a function to each in the ExceptionBugsnagStackFrame
filterStackFrames :: (BugsnagStackFrame -> Bool) -> BeforeNotify #
Filter out StackFrames matching a predicate
setStackFramesCode :: CodeIndex -> BeforeNotify #
Set using the given indexbsfCode
setStackFramesInProject :: (FilePath -> Bool) -> BeforeNotify #
Set using the given predicate, applied to the FilenamebsIsInProject
setStackFramesInProjectBy :: (BugsnagStackFrame -> a) -> (a -> Bool) -> BeforeNotify #
setGroupingHash :: Text -> BeforeNotify #
Set beGroupingHash
setGroupingHashBy :: (BugsnagEvent -> Maybe Text) -> BeforeNotify #
Set based on the EventbeGroupingHash
Modifying the Event
updateEventFromException :: (BugsnagException -> BeforeNotify) -> BeforeNotify #
Update the based on its BugsnagEventBugsnagException
Use this instead of if you want to do other things to the
Event, such as set its updateException based on the Exception.beGroupingHash
updateEventFromOriginalException :: Exception e => (e -> BeforeNotify) -> BeforeNotify #
Update the based on the original exceptionBugsnagEvent
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 , you can (and should) use other
helpers:BeforeNotify
myBeforeNotify =
defaultBeforeNotify
. updateEventFromOriginalException asSqlError
. updateEventFromOriginalException asHttpError
. -- ...
asSqlError :: SqlError -> BeforeNotify
asSqlError SqlError{..} =
setGroupingHash sqlErrorCode . updateException $ ex -> ex
{ beErrorClass = sqlErrorCode
, beMessage = sqlErrorMessage
}
If there is no original exception, or the cast fails, the event is unchanged.
updateEventFromSession :: BugsnagSession -> BeforeNotify #
Update the Event's Context and User from the Session
updateEventFromWaiRequest :: Request -> BeforeNotify #
Set the events and BugsnagEventBugsnagDevice
This function redacts the following Request headers:
- Authorization
- Cookie
- X-XSRF-TOKEN (CSRF token header used by Yesod)
To avoid this, use .updateEventFromWaiRequestUnredacted
Modifying the Request
redactRequestHeaders :: [HeaderName] -> BeforeNotify #
Redact the given request headers
Headers like Authorization may contain information you don't want to report
to Bugsnag.
redactRequestHeaders ["Authorization", "Cookie"]
Simple setters
setDevice :: BugsnagDevice -> BeforeNotify #
Set the Event's Device
setRequest :: BugsnagRequest -> BeforeNotify #
Set the Event's Request
setStacktrace :: [BugsnagStackFrame] -> BeforeNotify #
Set the stacktrace on the reported exception
notifyBugsnagWith (setStacktrace [$(currentStackFrame) "myFunc"]) ...
Setting severity
setWarningSeverity :: BeforeNotify #
Set to WarningSeverity
setErrorSeverity :: BeforeNotify #
Set to ErrorSeverity
setInfoSeverity :: BeforeNotify #
Set to InfoSeverity