@@ -122,7 +122,10 @@ <h1 class="title">Module <code>pyControl4.error_handling</code></h1>
122122 elif await __checkResponseFormat(response_text) == "XML":
123123 dictionary = xmltodict.parse(response_text)
124124 if "C4ErrorResponse" in dictionary:
125- if dictionary["C4ErrorResponse"]["details"] in ERROR_DETAILS:
125+ if (
126+ "details" in dictionary["C4ErrorResponse"]
127+ and dictionary["C4ErrorResponse"]["details"] in ERROR_DETAILS
128+ ):
126129 exception = ERROR_DETAILS.get(dictionary["C4ErrorResponse"]["details"])
127130 raise exception(response_text)
128131 else:
@@ -131,14 +134,14 @@ <h1 class="title">Module <code>pyControl4.error_handling</code></h1>
131134 )
132135 raise exception(response_text)
133136 elif "code" in dictionary:
134- if dictionary["details"] in ERROR_DETAILS:
137+ if "details" in dictionary and dictionary["details"] in ERROR_DETAILS:
135138 exception = ERROR_DETAILS.get(dictionary["details"])
136139 raise exception(response_text)
137140 else:
138141 exception = ERROR_CODES.get(str(dictionary["code"]), C4Exception)
139142 raise exception(response_text)
140143 elif "error" in dictionary:
141- if dictionary["details"] in DIRECTOR_ERROR_DETAILS:
144+ if "details" in dictionary and dictionary["details"] in DIRECTOR_ERROR_DETAILS:
142145 exception = DIRECTOR_ERROR_DETAILS.get(dictionary["details"])
143146 raise exception(response_text)
144147 else:
@@ -175,7 +178,10 @@ <h2 id="parameters">Parameters</h2>
175178 elif await __checkResponseFormat(response_text) == "XML":
176179 dictionary = xmltodict.parse(response_text)
177180 if "C4ErrorResponse" in dictionary:
178- if dictionary["C4ErrorResponse"]["details"] in ERROR_DETAILS:
181+ if (
182+ "details" in dictionary["C4ErrorResponse"]
183+ and dictionary["C4ErrorResponse"]["details"] in ERROR_DETAILS
184+ ):
179185 exception = ERROR_DETAILS.get(dictionary["C4ErrorResponse"]["details"])
180186 raise exception(response_text)
181187 else:
@@ -184,14 +190,14 @@ <h2 id="parameters">Parameters</h2>
184190 )
185191 raise exception(response_text)
186192 elif "code" in dictionary:
187- if dictionary["details"] in ERROR_DETAILS:
193+ if "details" in dictionary and dictionary["details"] in ERROR_DETAILS:
188194 exception = ERROR_DETAILS.get(dictionary["details"])
189195 raise exception(response_text)
190196 else:
191197 exception = ERROR_CODES.get(str(dictionary["code"]), C4Exception)
192198 raise exception(response_text)
193199 elif "error" in dictionary:
194- if dictionary["details"] in DIRECTOR_ERROR_DETAILS:
200+ if "details" in dictionary and dictionary["details"] in DIRECTOR_ERROR_DETAILS:
195201 exception = DIRECTOR_ERROR_DETAILS.get(dictionary["details"])
196202 raise exception(response_text)
197203 else:
0 commit comments