Fix NotLoggedIn

This commit is contained in:
Mads Marquart
2020-01-25 15:07:04 +01:00
parent f8e110f180
commit 987993701f
2 changed files with 7 additions and 9 deletions

View File

@@ -46,6 +46,11 @@ class ParseError(FacebookError):
return msg.format(self.message, self.data) return msg.format(self.message, self.data)
@attr.s(slots=True, auto_exc=True)
class NotLoggedIn(FacebookError):
"""Raised by Facebook if the client has been logged out."""
@attr.s(slots=True, auto_exc=True) @attr.s(slots=True, auto_exc=True)
class ExternalError(FacebookError): class ExternalError(FacebookError):
"""Base class for errors that Facebook return.""" """Base class for errors that Facebook return."""
@@ -86,13 +91,6 @@ class InvalidParameters(ExternalError):
""" """
@attr.s(slots=True, auto_exc=True)
class NotLoggedIn(ExternalError):
"""Raised by Facebook if the client has been logged out."""
code = attr.ib()
@attr.s(slots=True, auto_exc=True) @attr.s(slots=True, auto_exc=True)
class PleaseRefresh(ExternalError): class PleaseRefresh(ExternalError):
"""Raised by Facebook if the client has been inactive for too long. """Raised by Facebook if the client has been inactive for too long.
@@ -108,7 +106,7 @@ def handle_payload_error(j):
return return
code = j["error"] code = j["error"]
if code == 1357001: if code == 1357001:
error_cls = NotLoggedIn raise NotLoggedIn(j["errorSummary"])
elif code == 1357004: elif code == 1357004:
error_cls = PleaseRefresh error_cls = PleaseRefresh
elif code in (1357031, 1545010, 1545003): elif code in (1357031, 1545010, 1545003):

View File

@@ -308,7 +308,7 @@ class Session:
# Fall back to searching with a regex # Fall back to searching with a regex
res = FB_DTSG_REGEX.search(r.text) res = FB_DTSG_REGEX.search(r.text)
if not res: if not res:
raise ValueError("Failed loading session, could not find fb_dtsg") raise _exception.NotLoggedIn("Could not find fb_dtsg")
fb_dtsg = res.group(1) fb_dtsg = res.group(1)
revision = int(r.text.split('"client_revision":', 1)[1].split(",", 1)[0]) revision = int(r.text.split('"client_revision":', 1)[1].split(",", 1)[0])