diff options
| author | 2019-02-28 23:28:45 +0000 | |
|---|---|---|
| committer | 2019-02-28 23:28:45 +0000 | |
| commit | 197ae2e053fdedbd8977b0712806c65fbb4e82c6 (patch) | |
| tree | 6b3b20a563b5c490a66f3ac54ae8d53db2ec7a2d /src | |
| parent | capitalise "PR" (Pull Request) (diff) | |
| signature | ||
Raise a specific exception in utils.http.request for "wrong content type"
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/http.py | 5 |
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) |
