Skip to content

Commit

Permalink
Adds an onFailure callback to delegate error handling to the app
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmit committed Jun 12, 2016
1 parent e10c5dd commit 2dd539d
Show file tree
Hide file tree
Showing 10 changed files with 84,158 additions and 6 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ function fastbootExpressMiddleware(distPath, options) {
if (error.name === "UnrecognizedURLError") {
next();
} else {
log(500, "Unknown Error: " + error.stack);
if (error.stack) {
res.status(500).send(error.stack);
if (typeof opts.onFailure === 'function') {
opts.onFailure(error, req, res, next);
} else {
res.sendStatus(500);
log(500, "Unknown Error: " + error.stack);
if (error.stack) {
res.status(500).send(error.stack);
} else {
res.sendStatus(500);
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "An Express middleware for rendering Ember apps with FastBoot",
"main": "index.js",
"scripts": {
"test": "mocha"
"test": "./node_modules/mocha/bin/mocha",
"test:watch": "./node_modules/mocha/bin/mocha -w"
},
"repository": {
"type": "git",
Expand Down
359 changes: 359 additions & 0 deletions test/fixtures/error-case/assets/fastboot-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2dd539d

Please sign in to comment.