File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,8 +94,15 @@ export default class DBSQLClient extends EventEmitter implements IDBSQLClient {
9494 this . client = this . thrift . createClient ( TCLIService , this . connection . getConnection ( ) ) ;
9595
9696 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+ }
99106 } ) ;
100107
101108 this . connection . getConnection ( ) . on ( 'reconnecting' , ( params : { delay : number ; attempt : number } ) => {
You can’t perform that action at this time.
0 commit comments