Skip to content

Commit 727011b

Browse files
committed
Show the error details when failing to register a schema
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.
1 parent 8fa238a commit 727011b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

confluent_kafka/avro/cached_schema_registry_client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,17 @@ def register(self, subject, avro_schema):
217217
body = {'schema': json.dumps(avro_schema.to_json())}
218218
result, code = self._send_request(url, method='POST', body=body)
219219
if (code == 401 or code == 403):
220-
raise ClientError("Unauthorized access. Error code:" + str(code))
220+
raise ClientError("Unauthorized access. Error code:" + str(code)
221+
+ " message:" + str(result))
221222
elif code == 409:
222-
raise ClientError("Incompatible Avro schema:" + str(code))
223+
raise ClientError("Incompatible Avro schema:" + str(code)
224+
+ " message:" + str(result))
223225
elif code == 422:
224-
raise ClientError("Invalid Avro schema:" + str(code))
226+
raise ClientError("Invalid Avro schema:" + str(code)
227+
+ " message:" + str(result))
225228
elif not (code >= 200 and code <= 299):
226-
raise ClientError("Unable to register schema. Error code:" + str(code))
229+
raise ClientError("Unable to register schema. Error code:" + str(code)
230+
+ " message:" + str(result))
227231
# result is a dict
228232
schema_id = result['id']
229233
# cache it

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy