From 4e132e8857f15783d230d5e439dc80702d13842a Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Tue, 6 Oct 2020 11:50:29 +0200 Subject: [PATCH] Raise exception on HTTP errors in backend. Closes #34. --- bigbluebutton/api/bigbluebutton.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bigbluebutton/api/bigbluebutton.py b/bigbluebutton/api/bigbluebutton.py index e4495e4..aec5215 100644 --- a/bigbluebutton/api/bigbluebutton.py +++ b/bigbluebutton/api/bigbluebutton.py @@ -37,6 +37,11 @@ except ImportError: # pragma: no cover logger = logging.getLogger(__name__) +class BigBlueButtonError(Exception): + """Exception raised when a BigBlueButton backends encounters an error.""" + pass + + @dataclass class BigBlueButton: """One BigBlueButton server. @@ -134,6 +139,9 @@ class BigBlueButton: url = self._build_url(call, params) res = self._session.get(url, timeout=self.request_timeout) + if res.status_code != 200: + raise BigBlueButtonError(f"Backend returned HTTP status {res.status_code}.") + xml = xmltodict.parse(res.text) return xml["response"] -- GitLab