diff --git a/lib/datasource.js b/lib/datasource.js index 33e9add5..1c96fd74 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -499,7 +499,15 @@ DataSource.prototype.setup = function(dsName, settings) { debug('Connection fails: %s\nIt will be retried for the next request.', err); } else { g.error('Connection fails: %s\nIt will be retried for the next request.', err); - this.emit('error', err); + if (settings.catchFailure) { + try { + this.emit('error', err); + } catch (error) { + console.log(error); + } + } else { + this.emit('error', err); + } } } else { // Either lazyConnect or connector initialize() defers the connection