Skip to content

Commit 0b41ff5

Browse files
committed
Add error handlers
1 parent d43db31 commit 0b41ff5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

helpers/mu/server.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ app.use('/', function(req, res, next) {
1313
next();
1414
});
1515

16+
// development error handler - printing stacktrace
17+
if (app.get('env') === 'development') {
18+
app.use(function(err, req, res, next) {
19+
res.status(err.status || 400);
20+
res.json({
21+
errors: [ {title: err.message} ]
22+
});
23+
});
24+
}
25+
26+
// production error handler - no stacktrace
27+
app.use(function(err, req, res, next) {
28+
res.status(err.status || 400);
29+
res.json({
30+
errors: [ {title: err.message} ]
31+
});
32+
});
33+
1634
// start server
1735
app.listen( 80, function() {
1836
console.log('Starting server on port 80');

0 commit comments

Comments
 (0)