Add error handling for when the listener has been logged out
This commit is contained in:
@@ -130,11 +130,10 @@ class Mqtt(object):
|
|||||||
log.debug("Fetching MQTT sequence ID")
|
log.debug("Fetching MQTT sequence ID")
|
||||||
# Same request as in `Client.fetchThreadList`
|
# Same request as in `Client.fetchThreadList`
|
||||||
(j,) = state._graphql_requests(_graphql.from_doc_id("1349387578499440", params))
|
(j,) = state._graphql_requests(_graphql.from_doc_id("1349387578499440", params))
|
||||||
try:
|
sequence_id = j["viewer"]["message_threads"]["sync_sequence_id"]
|
||||||
return int(j["viewer"]["message_threads"]["sync_sequence_id"])
|
if not sequence_id:
|
||||||
except (KeyError, ValueError):
|
raise _exception.FBchatNotLoggedIn("Failed fetching sequence id")
|
||||||
# TODO: Proper exceptions
|
return int(sequence_id)
|
||||||
raise
|
|
||||||
|
|
||||||
def _on_connect_handler(self, client, userdata, flags, rc):
|
def _on_connect_handler(self, client, userdata, flags, rc):
|
||||||
if rc == 21:
|
if rc == 21:
|
||||||
@@ -287,6 +286,8 @@ class Mqtt(object):
|
|||||||
# This error is wrongly classified
|
# This error is wrongly classified
|
||||||
# See https://github.com/eclipse/paho.mqtt.python/issues/340
|
# See https://github.com/eclipse/paho.mqtt.python/issues/340
|
||||||
log.warning("Connection error, retrying")
|
log.warning("Connection error, retrying")
|
||||||
|
elif rc == paho.mqtt.client.MQTT_ERR_CONN_REFUSED:
|
||||||
|
raise _exception.FBchatNotLoggedIn("MQTT connection refused")
|
||||||
else:
|
else:
|
||||||
err = paho.mqtt.client.error_string(rc)
|
err = paho.mqtt.client.error_string(rc)
|
||||||
log.error("MQTT Error: %s", err)
|
log.error("MQTT Error: %s", err)
|
||||||
|
Reference in New Issue
Block a user