Link to Papertrail logs in error messages

This commit is contained in:
Michael Schmatz 2014-11-28 14:37:54 -05:00
parent 71d7ac5e11
commit 6cb46aafa8
2 changed files with 6 additions and 1 deletions

View file

@ -16,6 +16,9 @@ module.exports.sendHipChatMessage = sendHipChatMessage = (message) ->
#log.info "Got HipChat patch response:", body
module.exports.sendTowerHipChatMessage = sendTowerHipChatMessage = (message) ->
secondsFromEpoch = Math.floor(new Date().getTime() / 1000)
link = "<a href=\"https://papertrailapp.com/groups/488214/events?time=#{secondsFromEpoch}\">PaperTrail</a>"
message = "#{message} #{link}"
return unless key = config.hipchatTowerAPIKey
roomID = 318356
form =

View file

@ -43,7 +43,9 @@ setupErrorMiddleware = (app) ->
app.use (err, req, res, next) ->
if err
res.status(500).send(error: "Something went wrong!")
hipchat.sendTowerHipChatMessage("The server crashed. Path: #{req.path}, Stack trace: <br> <code>#{err.stack}</code>")
message = "Express got an error. Path: #{req.path}, message: #{err.message}"
log.error "#{message}, stack: #{err.stack}"
hipchat.sendTowerHipChatMessage(message)
else
next(err)
setupExpressMiddleware = (app) ->