Permalink
Browse files

Bubble query errors up to results object if there are no listeners se…

…t up at the time
  • Loading branch information...
1 parent 4272096 commit 9118c3fb402c4cd75b9f88d8c9cbabd88e6bf437 @mscdex committed Sep 26, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/Client.js
View
@@ -104,8 +104,12 @@ function Client() {
if (err.code === 2013 || err.code === 10001/*ERROR_HANGUP*/) {
// connection closed by server
self.emit('error', err);
- } else
- self._curResults._curQuery.emit('error', err);
+ } else {
+ if (self._curResults._curQuery.listeners('error').length > 0)
+ self._curResults._curQuery.emit('error', err);
+ else
+ self._curResults.emit('error', err, self._curResults._curQuery);
+ }
};
this._client.on('query.error', fnQueryErr);
this._client.on('query.row.error', fnQueryErr);

0 comments on commit 9118c3f

Please sign in to comment.