mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
added nicer error messages for failed view lookup. Closes #1065
This commit is contained in:
parent
082ba88084
commit
04d43d60b7
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user