mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
native bindings emit Error objects on all 'error' events
This commit is contained in:
parent
b728186a7d
commit
c7774ca0a8
@ -109,16 +109,25 @@ var clientBuilder = function(config) {
|
||||
//proxy some events to active query
|
||||
connection.on('_row', function(row) {
|
||||
connection._activeQuery.handleRow(row);
|
||||
})
|
||||
});
|
||||
|
||||
//TODO: emit more native error properties (make it match js error)
|
||||
connection.on('_error', function(err) {
|
||||
//create Error object from object literal
|
||||
var error = new Error(err.message || "Unknown native driver error");
|
||||
for(var key in err) {
|
||||
error[key] = err[key];
|
||||
}
|
||||
|
||||
//give up on trying to wait for named query prepare
|
||||
this._namedQuery = false;
|
||||
if(connection._activeQuery) {
|
||||
connection._activeQuery.handleError(err);
|
||||
connection._activeQuery.handleError(error);
|
||||
} else {
|
||||
connection.emit('error', err);
|
||||
connection.emit('error', error);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
connection.on('_readyForQuery', function() {
|
||||
var q = this._activeQuery;
|
||||
//a named query finished being prepared
|
||||
@ -131,6 +140,7 @@ var clientBuilder = function(config) {
|
||||
connection._pulseQueryQueue();
|
||||
}
|
||||
});
|
||||
|
||||
return connection;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user