Skip to content

Commit

Permalink
Do not render when model has errored
Browse files Browse the repository at this point in the history
  • Loading branch information
ishbu committed Aug 14, 2015
1 parent 87ec3db commit 1c84fc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/App.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ App.prototype.createPage = function(req, res, next) {
this.emit('model', model);
var page = new this.Page(this, model, req, res);
if (next) {
model.on('error', next);
model.on('error', function(err){
model.hasErrored = true;
next(err);
});
page.on('error', next);
}
return page;
Expand Down
1 change: 1 addition & 0 deletions lib/Page.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Page.prototype.render = function(status, ns) {
var page = this;
this.model.destroy('$components');
this.model.bundle(function(err, bundle) {
if (page.model.hasErrored) return;
if (err) return page.emit('error', err);
var scripts = '<script async src="' + page.app.scriptUrl + '"></script>' +
'<script type="application/json">' + stringifyBundle(bundle) + '</script>';
Expand Down

0 comments on commit 1c84fc4

Please sign in to comment.