Skip to content

Commit c93e9f0

Browse files
committed
Adds an onFailure callback to delegate error handling to the app
1 parent e10c5dd commit c93e9f0

File tree

10 files changed

+84157
-6
lines changed

10 files changed

+84157
-6
lines changed

index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ function fastbootExpressMiddleware(distPath, options) {
5555
if (error.name === "UnrecognizedURLError") {
5656
next();
5757
} else {
58-
log(500, "Unknown Error: " + error.stack);
59-
if (error.stack) {
60-
res.status(500).send(error.stack);
58+
if (typeof opts.onFailure === 'function') {
59+
opts.onFailure(error, req, res, next);
6160
} else {
62-
res.sendStatus(500);
61+
log(500, "Unknown Error: " + error.stack);
62+
if (error.stack) {
63+
res.status(500).send(error.stack);
64+
} else {
65+
res.sendStatus(500);
66+
}
6367
}
6468
}
6569
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "An Express middleware for rendering Ember apps with FastBoot",
55
"main": "index.js",
66
"scripts": {
7-
"test": "mocha"
7+
"test": "./node_modules/mocha/bin/mocha",
8+
"test:watch": "./node_modules/mocha/bin/mocha -w"
89
},
910
"repository": {
1011
"type": "git",

test/fixtures/error-case/assets/fastboot-test.js

Lines changed: 359 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)