@@ -317,28 +317,36 @@ class Client extends EventEmitter {
317317 // if we receieve an error event or error message
318318 // during the connection process we handle it here
319319 _handleErrorWhileConnecting ( err ) {
320- if ( this . _connectionError ) {
321- // TODO(bmc): this is swallowing errors - we shouldn't do this
322- return
323- }
324- this . _connectionError = true
325- clearTimeout ( this . connectionTimeoutHandle )
326- if ( this . _connectionCallback ) {
327- return this . _connectionCallback ( err )
320+ try {
321+ if ( this . _connectionError ) {
322+ // TODO(bmc): this is swallowing errors - we shouldn't do this
323+ return
324+ }
325+ this . _connectionError = true
326+ clearTimeout ( this . connectionTimeoutHandle )
327+ if ( this . _connectionCallback ) {
328+ return this . _connectionCallback ( err )
329+ }
330+ this . emit ( 'error' , err )
331+ } catch ( error ) {
332+ console . error ( error ) ;
328333 }
329- this . emit ( 'error' , err )
330334 }
331335
332336 // if we're connected and we receive an error event from the connection
333337 // this means the socket is dead - do a hard abort of all queries and emit
334338 // the socket error on the client as well
335339 _handleErrorEvent ( err ) {
336- if ( this . _connecting ) {
337- return this . _handleErrorWhileConnecting ( err )
340+ try {
341+ if ( this . _connecting ) {
342+ return this . _handleErrorWhileConnecting ( err )
343+ }
344+ this . _queryable = false
345+ this . _errorAllQueries ( err )
346+ this . emit ( 'error' , err )
347+ } catch ( error ) {
348+ console . error ( error ) ;
338349 }
339- this . _queryable = false
340- this . _errorAllQueries ( err )
341- this . emit ( 'error' , err )
342350 }
343351
344352 // handle error messages from the postgres backend
0 commit comments