Skip to content

Commit

Permalink
Add ability to use third party error tracking software for expressjs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dominathan authored and Robert-W committed Dec 19, 2018
1 parent fa9c6ee commit eafa222
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class Server {

// Configure middleware
configureMiddleware () {
//Enable error tracking request handler if supplied in config
if (this.config.errorTracking && this.config.errorTracking.requestHandler) {
this.app.use(this.config.errorTracking.requestHandler());
}
// Enable stack traces
this.app.set('showStackError', !this.env.IS_PRODUCTION);
// Add compression
Expand Down Expand Up @@ -183,6 +187,11 @@ class Server {

// Setup error routes
setErrorRoutes () {
//Enable error tracking error handler if supplied in config
if (this.config.errorTracking && this.config.errorTracking.errorHandler) {
this.app.use(this.config.errorTracking.errorHandler());
}

// Generic catch all error handler
// Errors should be thrown with next and passed through
this.app.use((err, req, res, next) => {
Expand Down

0 comments on commit eafa222

Please sign in to comment.