-
Notifications
You must be signed in to change notification settings - Fork 43
Forward errors along to error handling middlewares #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,17 +36,24 @@ function fastbootExpressMiddleware(distPath, options) { | |
| result.html() | ||
| .then(html => { | ||
| let headers = result.headers; | ||
| let statusMessage = result.error ? 'NOT OK ' : 'OK '; | ||
|
|
||
| for (var pair of headers.entries()) { | ||
| res.set(pair[0], pair[1]); | ||
| } | ||
|
|
||
| log(result.statusCode, 'OK ' + path); | ||
| if (result.error) { | ||
| log("RESILIENT MODE CAUGHT:", result.error.stack); | ||
| next(result.error); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| log(result.statusCode, statusMessage + path); | ||
| res.status(result.statusCode); | ||
| res.send(html); | ||
| }) | ||
| .catch(error => { | ||
| console.log(error.stack); | ||
| log(500, error.stack); | ||
| next(error); | ||
| res.sendStatus(500); | ||
|
||
| }); | ||
| } | ||
|
|
@@ -55,6 +62,7 @@ function fastbootExpressMiddleware(distPath, options) { | |
| if (error.name === "UnrecognizedURLError") { | ||
| next(); | ||
| } else { | ||
| next(error); | ||
|
||
| log(500, "Unknown Error: " + error.stack); | ||
| if (error.stack) { | ||
| res.status(500).send(error.stack); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readme update: if you are in resilient mode you delegate the error handling to us.