Skip to content

Show the error details when failing to register a schema #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions confluent_kafka/avro/cached_schema_registry_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,17 @@ def register(self, subject, avro_schema):
body = {'schema': json.dumps(avro_schema.to_json())}
result, code = self._send_request(url, method='POST', body=body)
if (code == 401 or code == 403):
raise ClientError("Unauthorized access. Error code:" + str(code))
raise ClientError("Unauthorized access. Error code:" + str(code)
+ " message:" + str(result))
elif code == 409:
raise ClientError("Incompatible Avro schema:" + str(code))
raise ClientError("Incompatible Avro schema:" + str(code)
+ " message:" + str(result))
elif code == 422:
raise ClientError("Invalid Avro schema:" + str(code))
raise ClientError("Invalid Avro schema:" + str(code)
+ " message:" + str(result))
elif not (code >= 200 and code <= 299):
raise ClientError("Unable to register schema. Error code:" + str(code))
raise ClientError("Unable to register schema. Error code:" + str(code)
+ " message:" + str(result))
# result is a dict
schema_id = result['id']
# cache it
Expand Down