@@ -483,12 +483,13 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
483483 return ;
484484 }
485485
486- Logger . debug ( 'ICE connection state changed to '
487- + event . currentTarget . iceConnectionState ) ;
488- if ( event . currentTarget . iceConnectionState === 'closed'
489- || event . currentTarget . iceConnectionState === 'failed' ) {
490- this . _rejectPromise (
491- new ConferenceError ( 'ICE connection failed or closed.' ) ) ;
486+ Logger . debug ( 'ICE connection state changed to ' +
487+ event . currentTarget . iceConnectionState ) ;
488+ if ( event . currentTarget . iceConnectionState === 'closed' ||
489+ event . currentTarget . iceConnectionState === 'failed' ) {
490+ if ( event . currentTarget . iceConnectionState === 'failed' ) {
491+ this . _handleError ( 'ICE connection failed.' ) ;
492+ }
492493 // Fire ended event if publication or subscription exists.
493494 this . _fireEndedEventOnPublicationOrSubscription ( ) ;
494495 }
@@ -583,17 +584,20 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
583584 }
584585
585586 _errorHandler ( errorMessage ) {
587+ return this . _handleError ( errorMessage ) ;
588+ }
589+
590+ _handleError ( errorMessage ) {
591+ const error = new ConferenceError ( errorMessage ) ;
586592 const p = this . _publishPromise || this . _subscribePromise ;
587593 if ( p ) {
588- p . reject ( new ConferenceError ( errorMessage ) ) ;
589- return ;
594+ return this . _rejectPromise ( error ) ;
590595 }
591596 const dispatcher = this . _publication || this . _subscription ;
592597 if ( ! dispatcher ) {
593598 Logger . warning ( 'Neither publication nor subscription is available.' ) ;
594599 return ;
595600 }
596- const error = new ConferenceError ( errorMessage ) ;
597601 const errorEvent = new ErrorEvent ( 'error' , {
598602 error : error ,
599603 } ) ;
0 commit comments