Browse Source

adds 500.md template and error handling in production (#65)

* adds "use strict" clause and use of const and let wherever possible

* single quotes on 'use strict'

* adds custom 500 error page when in production environment (no stack traces)

* changes type from '500' to 'error' in 500.md file

* add tags (#64)

* add travis to slack

* add tags

* adds custom 500 error page when in production environment (no stack traces)

* changes type from '500' to 'error' in 500.md file

* Revert "Merge remote-tracking branch 'origin/master'"

This reverts commit f80104ee42ad6508f1c87958f498adfabc1e62f2, reversing
changes made to e303e3807f.

revert merge
pull/71/head
Nuno Faria 5 years ago
committed by Cian Butler
parent
commit
8a8e6feee9
2 changed files with 15 additions and 6 deletions
  1. +9
    -6
      app.js
  2. +6
    -0
      source/500.md

+ 9
- 6
app.js View File

@@ -180,17 +180,20 @@ app.use(function (req, res, next) {
});

// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
app.use(function (err, req, res, next) {
if (app.get('env') === 'development') {
// development error handler
// will print stacktrace
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
} else {
// production error handler
res.redirect('/500.html');
}
});

// production error handler
// no stacktraces leaked to user


+ 6
- 0
source/500.md View File

@@ -0,0 +1,6 @@
---
title: 500 Error
type: 'error'
---

An internal error as occurred.

Loading…
Cancel
Save