Skip to content

Commit a633e2f

Browse files
committed
Fix the request_post to properly catch all exceptions
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent c7599f5 commit a633e2f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

dejacode_toolkit/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,10 @@ def request_post(self, url, **kwargs):
127127
if "timeout" not in kwargs:
128128
kwargs["timeout"] = self.default_timeout
129129

130+
# Do not `raise_for_status` as the response may contain valuable data
131+
# even on non 200 status code.
130132
try:
131133
response = self.session.post(url, **kwargs)
132-
response.raise_for_status()
133-
except requests.HTTPError as error:
134-
logger.error(f"{self.label} [HTTPError] {error}")
135-
136-
# The response may contain valuable data even on non 200 status code.
137-
try:
138134
return response.json()
139135
except (requests.RequestException, ValueError, TypeError) as exception:
140136
logger.error(f"{self.label} [Exception] {exception}")

0 commit comments

Comments
 (0)