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) {
109109 //proxy some events to active query
110110 connection . on ( '_row' , function ( row ) {
111111 connection . _activeQuery . handleRow ( row ) ;
112- } )
112+ } ) ;
113+
114+ //TODO: emit more native error properties (make it match js error)
113115 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+
114122 //give up on trying to wait for named query prepare
115123 this . _namedQuery = false ;
116124 if ( connection . _activeQuery ) {
117- connection . _activeQuery . handleError ( err ) ;
125+ connection . _activeQuery . handleError ( error ) ;
118126 } else {
119- connection . emit ( 'error' , err ) ;
127+ connection . emit ( 'error' , error ) ;
120128 }
121- } )
129+ } ) ;
130+
122131 connection . on ( '_readyForQuery' , function ( ) {
123132 var q = this . _activeQuery ;
124133 //a named query finished being prepared
@@ -131,6 +140,7 @@ var clientBuilder = function(config) {
131140 connection . _pulseQueryQueue ( ) ;
132141 }
133142 } ) ;
143+
134144 return connection ;
135145} ;
136146
You can’t perform that action at this time.
0 commit comments