pbrisbin / bugsnag-haskell

Bugsnag error reporter for Haskell
10 stars 7 forks source link

Make BugsnagSettings pure #21

Closed pbrisbin closed 6 years ago

pbrisbin commented 6 years ago

This means that we can't rely on application state in the global before-notify. For example:

, bsBeforeNotify = \event -> do
    request <- waiRequest
    pure $ updateEventFromRequest request event

-- Later
notifyBugsnag settings ex

Instead, we can only do pure things there:

, bsBeforeNotify = setWarning

And need to use notifyBugsnagWith for other stuff:

errorHandler (InternalError msg) = do
    request <- waiRequest

    let ex = bugsnagExceptionFromErrorMessage msg
        beforeNotify = updateEventFromRequest request

    notifyBugsnagWith beforeNotify settings ex

This may be perfectly acceptable and worth the simplification. The only real downside is that we can't use catchBugsnag as-is if we want to be able to inject a context-aware before-notify. Of course, we could implement a catchBugsnagWith if that becomes problematic.