added nicer error messages for failed view lookup. Closes #1065

This commit is contained in:
TJ Holowaychuk 2012-04-02 15:47:10 -07:00
parent 082ba88084
commit 04d43d60b7
2 changed files with 16 additions and 1 deletions

View File

@ -516,6 +516,10 @@ app.render = function(name, options, fn){
, engines: engines
});
if (!view.path) {
return fn(new Error('Failed to lookup view "' + name + '"'));
}
// prime the cache
if (opts.cache) cache[name] = view;
}

View File

@ -54,6 +54,17 @@ describe('app', function(){
})
})
describe('when the file does not exist', function(){
it('should provide a helpful error', function(done){
var app = express();
app.set('views', __dirname + '/fixtures');
app.render('rawr.jade', function(err){
err.message.should.equal('Failed to lookup view "rawr.jade"');
done();
});
})
})
describe('when an error occurs', function(){
it('should invoke the callback', function(done){
var app = express();