Skip to content

Commit 9d090bc

Browse files
committed
Propagate errors during queries to the Query
1 parent 0701038 commit 9d090bc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/client.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,18 @@ p.submit = function(connection) {
128128
var handleDatarow = function(msg) {
129129
self.onDataRow(msg);
130130
};
131+
var handleError = function(msg) {
132+
self.emit('error', msg);
133+
connection.sync();
134+
};
131135
connection.on('rowDescription', handleRowDescription);
132136
connection.on('dataRow', handleDatarow);
137+
connection.on('error', handleError);
133138
connection.once('readyForQuery', function() {
134139
//remove all listeners
135140
connection.removeListener('rowDescription', handleRowDescription);
136141
connection.removeListener('dataRow', handleDatarow);
142+
connection.removeListener('error', handleError);
137143
self.emit('end');
138144
});
139145
};

test/integration/client/error-handling-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ var helper = require(__dirname + '/test-helper');
22

33
test('error handling', function(){
44
var client = helper.client();
5-
client.query("select omfg from yodas_soda where pixistix = 'zoiks!!!'");
6-
assert.emits(client, 'error', function(error) {
5+
var query = client.query("select omfg from yodas_soda where pixistix = 'zoiks!!!'");
6+
assert.emits(query, 'error', function(error) {
77
assert.equal(error.severity, "ERROR");
88
client.end();
99
});

0 commit comments

Comments
 (0)