How to call a function when participants lose connection (or other error)

Sometimes people don’t notice jitsi loses connection. So I would like to make a more obvious notification.

I tested the following code and unplugged my pc during a conversation/chat. But It doesn’t seem to throw an error:

api.addListener("error", function () {
    alert("jitsi error")
});

Does anyone know why this isn’t throwing an error on connection lost or a way to get an error on connection lost?

PS: my other event listeners are working fine.