Skip to content
Browse files

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

  • Loading branch information...
1 parent 082ba88 commit 04d43d60b780084626ebc71cada17afcc6f15e3c @tj tj committed
Showing with 16 additions and 1 deletion.
  1. +4 −0 lib/application.js
  2. +12 −1 test/app.render.js
View
4 lib/application.js
@@ -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
13 test/app.render.js
@@ -53,7 +53,18 @@ describe('app', function(){
done();
})
})
-
+
+ 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();

1 comment on commit 04d43d6

@gsf

Yes, that's a nicer message. Thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.