Private GIT

Skip to content
Snippets Groups Projects
Commit 4e79203b authored by Alexandre Beloin's avatar Alexandre Beloin
Browse files

Merge pull request #1662 from fernandog/trakt_errors

Trakt: Catch all internal server error and log a warning
parents 292e739c 8f5d2ad5
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,3 @@ class traktAuthException(traktException):
class traktServerBusy(traktException):
pass
class traktInternalError(traktException):
pass
......@@ -2,7 +2,7 @@ import requests
import json
from sickbeard import logger
from exceptions import traktException, traktAuthException, traktServerBusy, traktInternalError
from exceptions import traktException, traktAuthException, traktServerBusy
class TraktAPI():
def __init__(self, apikey, username=None, password=None, disable_ssl_verify=False, timeout=30):
......@@ -40,11 +40,12 @@ class TraktAPI():
logger.log(u"Retrying trakt api request: auth/login", logger.WARNING)
return self.validateAccount()
elif code == 401:
logger.log(u"Unauthorized. Please check your Trakt settings", logger.WARNING)
raise traktAuthException(e)
elif code == 503:
elif code in (500,501,503,504,520,521,522):
#http://docs.trakt.apiary.io/#introduction/status-codes
logger.log(u"Trakt may have some issues and it's unavailable. Try again later please", logger.WARNING)
raise traktServerBusy(e)
elif code == 500:
raise traktInternalError(e)
else:
raise traktException(e)
if 'token' in resp:
......@@ -81,8 +82,11 @@ class TraktAPI():
logger.log(u"Retrying trakt api request: %s" % path, logger.WARNING)
return self.traktRequest(path, data, method)
elif code == 401:
logger.log(u"Unauthorized. Please check your Trakt settings", logger.WARNING)
raise traktAuthException(e)
elif code == 503:
elif code in (500,501,503,504,520,521,522):
#http://docs.trakt.apiary.io/#introduction/status-codes
logger.log(u"Trakt may have some issues and it's unavailable. Try again later please", logger.WARNING)
raise traktServerBusy(e)
else:
raise traktException(e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment