@@ -36,7 +36,6 @@ var Client = module.exports = function (config) {
36
36
this . _startReading ( )
37
37
} )
38
38
39
- this . on ( '_queryError' , this . _onQueryError . bind ( this ) )
40
39
this . on ( 'result' , this . _onResult . bind ( this ) )
41
40
this . on ( 'readyForQuery' , this . _onReadyForQuery . bind ( this ) )
42
41
}
@@ -153,11 +152,7 @@ Client.prototype.end = function (cb) {
153
152
154
153
Client . prototype . _readError = function ( message ) {
155
154
var err = new Error ( message || this . pq . errorMessage ( ) )
156
- if ( this . _queryCallback ) {
157
- this . emit ( '_queryError' , err )
158
- } else {
159
- this . emit ( 'error' , err )
160
- }
155
+ this . emit ( 'error' , err )
161
156
}
162
157
163
158
Client . prototype . _stopReading = function ( ) {
@@ -175,7 +170,7 @@ Client.prototype._emitResult = function (pq) {
175
170
var status = pq . resultStatus ( )
176
171
switch ( status ) {
177
172
case 'PGRES_FATAL_ERROR' :
178
- this . _readError ( )
173
+ this . _queryError = new Error ( this . pq . resultErrorMessage ( ) )
179
174
break
180
175
181
176
case 'PGRES_TUPLES_OK' :
@@ -291,10 +286,6 @@ Client.prototype._dispatchQuery = function (pq, fn, cb) {
291
286
this . _waitForDrain ( pq , cb )
292
287
}
293
288
294
- Client . prototype . _onQueryError = function ( err ) {
295
- this . _queryError = err
296
- }
297
-
298
289
Client . prototype . _onResult = function ( result ) {
299
290
if ( this . _resultCount === 0 ) {
300
291
this . _results = result
0 commit comments