File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ var helper = require(__dirname + '/test-helper');
22
33test ( '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 } ) ;
You can’t perform that action at this time.
0 commit comments