publishers: zulip: Catch general HTTPErrors. (#107)

* publishers: zulip: Catch general HTTPErrors.
This commit is contained in:
Giacomo Leidi 2021-11-28 16:50:22 +01:00 committed by GitHub
parent 227ce22d57
commit d6714f2142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -18,6 +18,7 @@ from mobilizon_reshare.publishers.exceptions import (
InvalidResponse,
ZulipError,
InvalidMessage,
HTTPResponseError,
)
@ -109,7 +110,15 @@ class ZulipPlatform(AbstractPlatform):
raise_error=InvalidBot,
)
def _validate_response(self, res) -> dict:
def _validate_response(self, res: Response) -> dict:
try:
res.raise_for_status()
except requests.exceptions.HTTPError as e:
self._log_debug(str(res))
self._log_error(
str(e), raise_error=HTTPResponseError,
)
# See https://zulip.com/api/rest-error-handling
try:
data = res.json()