diff --git a/lib/ExpressRedisCache.js b/lib/ExpressRedisCache.js index 9cb05aa..0d9585e 100644 --- a/lib/ExpressRedisCache.js +++ b/lib/ExpressRedisCache.js @@ -80,9 +80,10 @@ module.exports = (function () { /** If client can emit */ - if ( this.client.on ) { + if ( this.client && this.client.on ) { this.client.on('error', function (error) { - this.emit('error', error); + this.connected = false; + this.emit('message', 'Redis is unavailable or not running'); }.bind(this)); this.client.on('connect', function () { diff --git a/test/express.js b/test/express.js index 3a06750..f9e061a 100644 --- a/test/express.js +++ b/test/express.js @@ -226,4 +226,4 @@ describe ( 'test with small express server', function () { done(); }); -}); \ No newline at end of file +});