mirror of
https://github.com/flobz/psa_car_controller.git
synced 2026-08-21 08:56:29 +00:00
chore: better error message
This commit is contained in:
committed by
Florian BEZANNIER
parent
643b537952
commit
e505a2a163
@@ -21,7 +21,7 @@ def rate_limit(limit, every):
|
||||
timer.daemon = True
|
||||
timer.start()
|
||||
else:
|
||||
raise RateLimitException
|
||||
raise RateLimitException(func.__name__)
|
||||
|
||||
return wrapper
|
||||
|
||||
@@ -47,7 +47,8 @@ def parse_hour(s):
|
||||
|
||||
|
||||
class RateLimitException(Exception):
|
||||
pass
|
||||
def __init__(self, func_name):
|
||||
super().__init__(f"Rate limit exceeded for {func_name}")
|
||||
|
||||
|
||||
def get_positions(locations):
|
||||
|
||||
@@ -192,7 +192,10 @@ class RemoteClient:
|
||||
self.remote_token_last_update = datetime.now()
|
||||
self.mqtt_client.username_pw_set("IMA_OAUTH_ACCESS_TOKEN", self.remoteCredentials.access_token)
|
||||
return True
|
||||
except (RequestException, RateLimitException, KeyError, AttributeError, RemoteException):
|
||||
except RateLimitException as e:
|
||||
logger.error("Can't refresh remote token please wait... %s", e)
|
||||
return False
|
||||
except (RequestException, KeyError, AttributeError, RemoteException):
|
||||
logger.exception("Can't refresh remote token, please redo otp procedure")
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user