Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
added another exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Phillips committed Nov 6, 2020
1 parent 680ddc3 commit 436b98c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
13 changes: 5 additions & 8 deletions blizzardapi/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import requests
from requests.exceptions import RequestException

from .exceptions import BlizzardApiRequestException
from .exceptions import (
BlizzardApiRequestException,
BlizzardApiResponseExeception,
)


class Api:
Expand Down Expand Up @@ -34,16 +37,10 @@ def _get_client_token(self, region):
return self._response_handler(response)

def _response_handler(self, response):
if not response.ok:
msg = (
f"Invalid response - {response.status_code} for {response.url}"
)
raise BlizzardApiRequestException(msg)

try:
json = response.json()
except Exception as e:
raise BlizzardApiRequestException(str(e))
raise BlizzardApiResponseExeception(str(e))

return json

Expand Down
4 changes: 4 additions & 0 deletions blizzardapi/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ class BlizzardApiException(Exception):

class BlizzardApiRequestException(BlizzardApiException):
pass


class BlizzardApiResponseExeception(BlizzardApiException):
pass
15 changes: 11 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import setuptools

__version__ = "1.1.1"
__version__ = "1.1.2"

with open("README.md", "r") as fh:
long_description = fh.read()
Expand All @@ -21,14 +21,21 @@
url="https://github.com/trevorphillips/python-blizzardapi",
packages=setuptools.find_packages(),
install_requires=install_requirements,
python_requires=">=3.6",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
],
python_requires=">=3.6",
)

0 comments on commit 436b98c

Please sign in to comment.