diff --git a/server_setup.coffee b/server_setup.coffee index a3f972caa..ad056068b 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -42,7 +42,10 @@ developmentLogging = (tokens, req, res) -> setupErrorMiddleware = (app) -> app.use (err, req, res, next) -> if err - res.status(500).send(error: "Something went wrong!") + if err.status and 400 <= err.status < 500 + res.status(err.status).send("Error #{err.status}") + return + res.status(err.status ? 500).send(error: "Something went wrong!") message = "Express error: #{req.method} #{req.path}: #{err.message}" log.error "#{message}, stack: #{err.stack}" hipchat.sendTowerHipChatMessage(message)