Skip to content

Commit

Permalink
Use ClickException rather exit to stop program after rate_limit exceeded
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Jan 14, 2024
1 parent 4f7b95a commit 22ae6b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plextraktsync/decorators/rate_limit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from functools import wraps
from time import sleep

from click import ClickException
from trakt.errors import RateLimitException

from plextraktsync.factory import logger
Expand All @@ -23,13 +24,12 @@ def wrapper(*args, **kwargs):
except RateLimitException as e:
if retry == retries:
logger.error(f"Trakt Error: {e}")
logger.error(
"Trakt API didn't respond properly, script will abort now. Please try again later."
)
logger.error(
f"Last call: {fn.__module__}.{fn.__name__}({args[1:]}, {kwargs})"
)
exit(1)
raise ClickException(
"Trakt API didn't respond properly, script will abort now. Please try again later."
)

seconds = e.retry_after
retry += 1
Expand Down

0 comments on commit 22ae6b1

Please sign in to comment.