Skip to content

Commit 11d05ef

Browse files
Matt Howlettjacopofar
Matt Howlett
andauthored
Show the error details when failing to register a schema (#1056)
When there are issues during the call to the schema registry, do not just report the HTTP code but also the response from the server. Co-authored-by: Jacopo Farina <jacopo.farina@flixbus.com>
1 parent c623c68 commit 11d05ef

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/confluent_kafka/avro/cached_schema_registry_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,17 @@ def register(self, subject, avro_schema):
215215
body = {'schema': str(avro_schema)}
216216
result, code = self._send_request(url, method='POST', body=body)
217217
if (code == 401 or code == 403):
218-
raise ClientError("Unauthorized access. Error code:" + str(code))
218+
raise ClientError("Unauthorized access. Error code:" + str(code)
219+
+ " message:" + str(result))
219220
elif code == 409:
220-
raise ClientError("Incompatible Avro schema:" + str(code))
221+
raise ClientError("Incompatible Avro schema:" + str(code)
222+
+ " message:" + str(result))
221223
elif code == 422:
222-
raise ClientError("Invalid Avro schema:" + str(code))
224+
raise ClientError("Invalid Avro schema:" + str(code)
225+
+ " message:" + str(result))
223226
elif not (code >= 200 and code <= 299):
224-
raise ClientError("Unable to register schema. Error code:" + str(code))
227+
raise ClientError("Unable to register schema. Error code:" + str(code)
228+
+ " message:" + str(result))
225229
# result is a dict
226230
schema_id = result['id']
227231
# cache it

0 commit comments

Comments
 (0)