mirror of
https://github.com/no2chem/wideq.git
synced 2025-05-17 15:50:10 -07:00
Special error for expired sessions
This commit is contained in:
parent
375ee62ce3
commit
04b4c7a6ce
14
wideq.py
14
wideq.py
@ -20,6 +20,13 @@ class APIError(Exception):
|
|||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
|
|
||||||
|
class NotLoggedInError(APIError):
|
||||||
|
"""The session is not valid or expired."""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def lgedm_post(url, data=None, access_token=None, session_id=None):
|
def lgedm_post(url, data=None, access_token=None, session_id=None):
|
||||||
"""Make an HTTP request in the format used by the API servers.
|
"""Make an HTTP request in the format used by the API servers.
|
||||||
|
|
||||||
@ -47,7 +54,12 @@ def lgedm_post(url, data=None, access_token=None, session_id=None):
|
|||||||
|
|
||||||
# Check for API errors.
|
# Check for API errors.
|
||||||
if 'returnCd' in out:
|
if 'returnCd' in out:
|
||||||
raise APIError(int(out['returnCd']), out['returnMsg'])
|
code = out['returnCd']
|
||||||
|
message = out['returnMsg']
|
||||||
|
if code == "0102":
|
||||||
|
raise NotLoggedInError()
|
||||||
|
else:
|
||||||
|
raise APIError(code, message)
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user