Try to fix TypeError in popup when handling exceptions.