From 197ae2e053fdedbd8977b0712806c65fbb4e82c6 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 28 Feb 2019 23:28:45 +0000 Subject: Raise a specific exception in utils.http.request for "wrong content type" --- src/utils/http.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/utils') 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) -- cgit v1.3.1-10-gc9f91