File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,15 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
94
94
this . client = this . thrift . createClient ( TCLIService , this . connection . getConnection ( ) ) ;
95
95
96
96
this . connection . getConnection ( ) . on ( 'error' , ( error : Error ) => {
97
- this . logger . log ( LogLevel . error , JSON . stringify ( error ) ) ;
98
- this . emit ( 'error' , error ) ;
97
+ // Error.stack already contains error type and message, so log stack if available,
98
+ // otherwise fall back to just error type + message
99
+ this . logger . log ( LogLevel . error , error . stack || `${ error . name } : ${ error . message } ` ) ;
100
+ try {
101
+ this . emit ( 'error' , error ) ;
102
+ } catch ( e ) {
103
+ // EventEmitter will throw unhandled error when emitting 'error' event.
104
+ // Since we already logged it few lines above, just suppress this behaviour
105
+ }
99
106
} ) ;
100
107
101
108
this . connection . getConnection ( ) . on ( 'reconnecting' , ( params : { delay : number ; attempt : number } ) => {
You can’t perform that action at this time.
0 commit comments