How do I catch the error, DOMException: RTCPeerConnection is gone (did you enter Offline mode?)?

How do I catch the following error?

Uncaught (in promise) DOMException: RTCPeerConnection is gone (did you enter Offline mode?)

This error only happens in Mozilla Firefox. I have tried many things and have searched the internet but I can’t find a solution that works.

How to replicate:

  1. Open a WebRTC app in Mozilla Firefox
  2. Setup a call,
  3. Once the call is established, disconnect your device from the Internet
  4. Reconnect the device after about 4 seconds

From what I was able to gather, this is a Mozilla bug with how they handle call reconnection when the network is changed or disconnected temporarily. Bear in mind that Chrome handles this well and even if the call terminates, this error doesn’t throw.

I found this link quite informative.