Added more infos to APIErrors

This commit is contained in:
RemixDev 2020-11-19 21:32:47 +01:00
parent 2b4fab5f19
commit 1834a87378
No known key found for this signature in database
GPG key ID: B33962B465BDB51C
3 changed files with 10 additions and 10 deletions

View file

@ -4,7 +4,7 @@ from deezer.gw import GW
from deezer.api import API
import json
__version__ = "0.0.5"
__version__ = "0.0.6"
class TrackFormats():
"""Number associtation for formats"""

View file

@ -39,14 +39,14 @@ class API:
if result_json['error']['code'] in [4, 700]:
eventlet.sleep(5)
return self.api_call(method, args)
if result_json['error']['code'] == 100: raise ItemsLimitExceededException
if result_json['error']['code'] == 200: raise PermissionException
if result_json['error']['code'] == 300: raise InvalidTokenException
if result_json['error']['code'] == 500: raise WrongParameterException
if result_json['error']['code'] == 501: raise MissingParameterException
if result_json['error']['code'] == 600: raise InvalidQueryException
if result_json['error']['code'] == 800: raise DataException
if result_json['error']['code'] == 901: raise IndividualAccountChangedNotAllowedException
if result_json['error']['code'] == 100: raise ItemsLimitExceededException(f"ItemsLimitExceededException: {method}")
if result_json['error']['code'] == 200: raise PermissionException(f"PermissionException: {method}")
if result_json['error']['code'] == 300: raise InvalidTokenException(f"InvalidTokenException: {method}")
if result_json['error']['code'] == 500: raise WrongParameterException(f"ParameterException: {method}")
if result_json['error']['code'] == 501: raise MissingParameterException(f"MissingParameterException: {method}")
if result_json['error']['code'] == 600: raise InvalidQueryException(f"InvalidQueryException: {method}")
if result_json['error']['code'] == 800: raise DataException(f"DataException: {method}")
if result_json['error']['code'] == 901: raise IndividualAccountChangedNotAllowedException(f"IndividualAccountChangedNotAllowedException: {method}")
raise APIError(json.dumps(result_json['error']))
return result_json

View file

@ -7,7 +7,7 @@ README = (HERE / "README.md").read_text()
setup(
name="deezer-py",
version="0.0.5",
version="0.0.6",
description="A wrapper for all Deezer's APIs",
long_description=README,
long_description_content_type="text/markdown",