Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,18 @@ p.submit = function(connection) {
var handleDatarow = function(msg) {
self.onDataRow(msg);
};
var handleError = function(msg) {
self.emit('error', msg);
connection.sync();
};
connection.on('rowDescription', handleRowDescription);
connection.on('dataRow', handleDatarow);
connection.on('error', handleError);
connection.once('readyForQuery', function() {
//remove all listeners
connection.removeListener('rowDescription', handleRowDescription);
connection.removeListener('dataRow', handleDatarow);
connection.removeListener('error', handleError);
self.emit('end');
});
};
Expand Down
4 changes: 2 additions & 2 deletions test/integration/client/error-handling-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var helper = require(__dirname + '/test-helper');

test('error handling', function(){
var client = helper.client();
client.query("select omfg from yodas_soda where pixistix = 'zoiks!!!'");
assert.emits(client, 'error', function(error) {
var query = client.query("select omfg from yodas_soda where pixistix = 'zoiks!!!'");
assert.emits(query, 'error', function(error) {
assert.equal(error.severity, "ERROR");
client.end();
});
Expand Down