Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use third party error tracking software for expressjs #118

Merged
merged 2 commits into from
Dec 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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