File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -109,16 +109,25 @@ var clientBuilder = function(config) {
109
109
//proxy some events to active query
110
110
connection . on ( '_row' , function ( row ) {
111
111
connection . _activeQuery . handleRow ( row ) ;
112
- } )
112
+ } ) ;
113
+
114
+ //TODO: emit more native error properties (make it match js error)
113
115
connection . on ( '_error' , function ( err ) {
116
+ //create Error object from object literal
117
+ var error = new Error ( err . message || "Unknown native driver error" ) ;
118
+ for ( var key in err ) {
119
+ error [ key ] = err [ key ] ;
120
+ }
121
+
114
122
//give up on trying to wait for named query prepare
115
123
this . _namedQuery = false ;
116
124
if ( connection . _activeQuery ) {
117
- connection . _activeQuery . handleError ( err ) ;
125
+ connection . _activeQuery . handleError ( error ) ;
118
126
} else {
119
- connection . emit ( 'error' , err ) ;
127
+ connection . emit ( 'error' , error ) ;
120
128
}
121
- } )
129
+ } ) ;
130
+
122
131
connection . on ( '_readyForQuery' , function ( ) {
123
132
var q = this . _activeQuery ;
124
133
//a named query finished being prepared
@@ -131,6 +140,7 @@ var clientBuilder = function(config) {
131
140
connection . _pulseQueryQueue ( ) ;
132
141
}
133
142
} ) ;
143
+
134
144
return connection ;
135
145
} ;
136
146
You can’t perform that action at this time.
0 commit comments