Just put a runtime bug in a piece of middleware:
Code:
app.use((req, res, next) => {
if (test500 && someNullObject.property) { // this is never executed }
});
Also if you just call next('someString') from a piece of middleware, that will divert into the error flow. If you haven't defined an error handler I think the default is 500.
FYI - you define an errorHandler with this special method signature:
Code:
app.use((err, req, res, next) => {
res.status(500).send(err);
});
http://expressjs.com/en/guide/error-handling.html
Last edited by suzzer99; 08-07-2017 at 05:44 PM.