Skip to content

Commit c07dcab

Browse files
committed
[Gordon] added a new error handler
1 parent 09ad419 commit c07dcab

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

error_handler_example.js

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ app.get("/", function(req, res, next) {
1111
console.log("You should not see this line in the console.");
1212
});
1313

14+
app.use("/", function(err, req, res, next) {
15+
if (err.message == "Unexpected network error") {
16+
console.log("I don't know how to handle network error. Pass it on.");
17+
next(err);
18+
}
19+
console.log("Unknown error. Pass it on.");
20+
next(err);
21+
});
22+
1423
app.use(function(err, req, res, next) {
1524
res.status(500);
1625
res.send({ error: "unknown error" });

0 commit comments

Comments
 (0)