aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2019-02-28 23:28:45 +0000
committerGravatar jesopo2019-02-28 23:28:45 +0000
commit197ae2e053fdedbd8977b0712806c65fbb4e82c6 (patch)
tree6b3b20a563b5c490a66f3ac54ae8d53db2ec7a2d /src/utils
parentcapitalise "PR" (Pull Request) (diff)
signature
Raise a specific exception in utils.http.request for "wrong content type"
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/http.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/http.py b/src/utils/http.py
index c246cdb9..29c3dbf9 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -16,6 +16,8 @@ class HTTPTimeoutException(HTTPException):
pass
class HTTPParsingException(HTTPException):
pass
+class HTTPWrongContentTypeException(HTTPException):
+ pass
def throw_timeout():
raise HTTPTimeoutException()
@@ -67,7 +69,8 @@ def request(url: str, method: str="GET", get_params: dict={},
soup = bs4.BeautifulSoup(response_content, parser)
return Response(response.status_code, soup, response_headers)
else:
- raise ValueError("Tried to soup non-html/non-xml data")
+ raise HTTPWrongContentTypeException(
+ "Tried to soup non-html/non-xml data")
data = response_content.decode(response.encoding or fallback_encoding)