From 5c006b3a5cfca0150cdab4d21ccd9821e0489841 Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Tue, 6 Oct 2020 12:02:35 +0200
Subject: [PATCH] Raise exception on FAILED resposne from backend. Closes #8.

---
 bigbluebutton/api/bigbluebutton.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bigbluebutton/api/bigbluebutton.py b/bigbluebutton/api/bigbluebutton.py
index 94e5f56..00f870c 100644
--- a/bigbluebutton/api/bigbluebutton.py
+++ b/bigbluebutton/api/bigbluebutton.py
@@ -147,6 +147,14 @@ class BigBlueButton:
         except Exception as ex:
             raise BigBlueButtonError("Failed to parse XML response from backend.") from ex
 
+        if xml.get("returncode", "FAILED").upper() == "FAILED":
+            message_key = res.get("messageKey", "")
+            message = res.get("message", "Unknown error")
+
+            ex = BigBlueButtonError(f"Backend returned FAILED response: {message}")
+            ex.message_key = message_key
+            raise ex
+
         return xml["response"]
 
     def create_meeting(self, do_create: bool = True, *args, **kwargs) -> Meeting:
-- 
GitLab