error notification to
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Run reportErrorS in IO Apr 16, 2018
.gitignore fixed error with logger text vs string. fixed deprecation for withman… Oct 21, 2016
.project-settings.yml add MonadLogger module Jul 2, 2013 improve Yesod documentation Jun 9, 2014
Setup.hs commit cabal files Jul 8, 2013
rollbar.cabal bump version Nov 15, 2018
stack.yaml Upgrade to lts-9 Aug 5, 2017


send error notifications to

I have used a few different error notification services.

Rollbar has:

  • good support for client-side javascript errors
  • a nice UI
  • a complete feature set (for me at least)


Below is some example Yesod code. Integration should be similar elsewhere:

  1. (optional) save Settings at startup
  2. have a global exception handler that notifies Rollbar
-- initialization code
-- in Yesod, this is in makeFoundation in Application.hs
    hn <- getHostName
    let rc = Rollbar.Settings
               { Rollbar.environment = Rollbar.Environment $ tshow $ appEnv conf
               , Rollbar.token =
                     Rollbar.ApiToken $ rollbarApiKeyServer $ appExtra conf
               , Rollbar.hostName = hn
    -- put rc into the foundation type

-- using in a global exception handler
-- in Yesod, this is in the Yesod typeclass in Foundation.hs
import qualified Rollbar
import Rollbar.MonadLogger (reportErrorS)

-- Add a field to the foundation data type
data App = App {
  , appRollbar :: Rollbar.Settings

errorHandler err@(InternalError e) = do
    app <- getYesod
    -- forking means error reporting to Rollbar won't hold up
    -- the response to the client
    unless development $ forkHandler ($logErrorS "errorHandler" . tshow) $ do
        muser <- maybeAuth
        let rollbarPerson (Entity uid user) =
                 {       = toPathPiece uid
                 , Rollbar.username = Nothing
                 ,    = Just $ emailToText $ userEmail user
        let rPerson = fmap rollbarPerson muser
        reportErrorS (appRollbar app)
                     (Rollbar.Options rPerson Nothing)
                     ($logDebugS) e
    defaultErrorHandler err 

errorHandler err = defaultErrorHandler err