parent
d7da22550d
commit
19a2eeb476
@ -97,12 +97,10 @@ describe('app', function(){
|
||||
|
||||
app.set('views', path.join(__dirname, 'fixtures'))
|
||||
|
||||
app.render('user.tmpl', function (err, str) {
|
||||
// nextTick to prevent cyclic
|
||||
process.nextTick(function(){
|
||||
err.message.should.match(/Cannot read property '[^']+' of undefined/);
|
||||
done();
|
||||
});
|
||||
app.render('user.tmpl', function (err) {
|
||||
assert.ok(err)
|
||||
assert.equal(err.name, 'RenderError')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -105,12 +105,12 @@ describe('res', function(){
|
||||
});
|
||||
|
||||
app.use(function(err, req, res, next){
|
||||
res.end(err.message);
|
||||
res.status(500).send('got error: ' + err.name)
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(/Cannot read property '[^']+' of undefined/, done);
|
||||
.expect(500, 'got error: RenderError', done)
|
||||
})
|
||||
})
|
||||
|
||||
@ -329,13 +329,15 @@ describe('res', function(){
|
||||
|
||||
app.use(function(req, res){
|
||||
res.render('user.tmpl', function (err) {
|
||||
res.end(err.message);
|
||||
if (err) {
|
||||
res.status(500).send('got error: ' + err.name)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(/Cannot read property '[^']+' of undefined/, done);
|
||||
.expect(500, 'got error: RenderError', done)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -13,6 +13,7 @@ module.exports = function renderFile(fileName, options, callback) {
|
||||
str = str.replace(variableRegExp, generateVariableLookup(options));
|
||||
} catch (e) {
|
||||
err = e;
|
||||
err.name = 'RenderError'
|
||||
}
|
||||
|
||||
callback(err, str);
|
||||
|
Loading…
Reference in New Issue
Block a user