Skip to content

Commit

Permalink
Don’t catch errors in development
Browse files Browse the repository at this point in the history
When an error occurs within a request, we display a generic error page to the user. This is useful for production but hides problems in development: instead of seeing a stacktrace or error, you see an Octocat. Cute but not helpful.

This disables the generic error handler middleware when `NODE_ENV=development`. This also adds `NODE_ENV=development` to `.env.example` so folks get this behaviour for free.
  • Loading branch information
Jordan Raine committed Aug 13, 2019
1 parent 2b1b79f commit 835a539
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Expand Up @@ -4,6 +4,7 @@ APP_URL=
WEBHOOK_SECRET=development
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
NODE_ENV=development
TUNNEL_PORT=4002
TUNNEL_SUBDOMAIN=<yourname>-jira

Expand Down
5 changes: 5 additions & 0 deletions lib/frontend/app.js
Expand Up @@ -117,10 +117,15 @@ module.exports = (appTokenGenerator) => {
Sentry.setContext('Body', req.body)
}
Sentry.captureException(err)
next(err)
})
}

const catchErrors = async (err, req, res, next) => {
if (process.env.NODE_ENV === 'development') {
return next(err)
}

const { data: info } = (await res.locals.client.apps.get({}))
const errorCodes = {
'Unauthorized': 401,
Expand Down

0 comments on commit 835a539

Please sign in to comment.