@@ -189,7 +189,7 @@ def register(self, subject, avro_schema, headers=None):
189189 msg = "Unable to register schema"
190190
191191 if msg is not None :
192- raise ClientError (message = msg , code = code , server_traceback = result )
192+ raise ClientError (message = msg , http_code = code , server_traceback = result )
193193
194194 schema_id = result ["id" ]
195195 self ._cache_schema (avro_schema , schema_id , subject )
@@ -214,7 +214,9 @@ def delete_subject(self, subject, headers=None):
214214
215215 result , code = self .request (url , method = "DELETE" , headers = headers )
216216 if not (status .HTTP_200_OK <= code < status .HTTP_300_MULTIPLE_CHOICES ):
217- raise ClientError ("Unable to delete subject" , code , server_traceback = result )
217+ raise ClientError (
218+ "Unable to delete subject" , http_code = code , server_traceback = result
219+ )
218220 return result
219221
220222 def get_by_id (self , schema_id , headers = None ):
@@ -252,7 +254,7 @@ def get_by_id(self, schema_id, headers=None):
252254 # bad schema - should not happen
253255 raise ClientError (
254256 f"Received bad schema (id { schema_id } )" ,
255- code ,
257+ http_code = code ,
256258 server_traceback = result ,
257259 )
258260
@@ -365,7 +367,9 @@ def test_compatibility(self, subject, avro_schema, version="latest", headers=Non
365367 elif status .HTTP_200_OK <= code < status .HTTP_300_MULTIPLE_CHOICES :
366368 return result .get ("is_compatible" )
367369 else :
368- log .error (f"Unable to check the compatibility: { code } " )
370+ log .error (
371+ f"Unable to check the compatibility: { code } . Traceback: { result } "
372+ )
369373 return False
370374 except Exception as e :
371375 log .error (f"request() failed: { e } " )
@@ -374,10 +378,13 @@ def test_compatibility(self, subject, avro_schema, version="latest", headers=Non
374378 def update_compatibility (self , level , subject = None , headers = None ):
375379 """
376380 PUT /config/(string: subject)
377- Update the compatibility level for a subject. Level must be one of:
381+ Update the compatibility level.
382+ If subject is None, the compatibility level is global.
378383
379384 Args:
380- level (str): ex: 'NONE','FULL','FORWARD', or 'BACKWARD'
385+ level (str): one of BACKWARD, BACKWARD_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE,
386+ FULL, FULL_TRANSITIVE, NONE
387+ subject (str): Option subject
381388 headers (dict): Extra headers to add on the requests
382389
383390 Returns:
@@ -394,8 +401,10 @@ def update_compatibility(self, level, subject=None, headers=None):
394401 result , code = self .request (url , method = "PUT" , body = body , headers = headers )
395402 if status .HTTP_200_OK <= code < status .HTTP_300_MULTIPLE_CHOICES :
396403 return result ["compatibility" ]
397- else :
398- raise ClientError (f"Unable to update level: { level } . Error code: { code } " )
404+
405+ raise ClientError (
406+ f"Unable to update level: { level } ." , http_code = code , server_traceback = result
407+ )
399408
400409 def get_compatibility (self , subject , headers = None ):
401410 """
@@ -406,8 +415,8 @@ def get_compatibility(self, subject, headers=None):
406415 headers (dict): Extra headers to add on the requests
407416
408417 Returns:
409- str: one of 'NONE','FULL',' FORWARD', or 'BACKWARD'
410-
418+ str: one of BACKWARD, BACKWARD_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE,
419+ FULL, FULL_TRANSITIVE, NONE
411420 Raises:
412421 ClientError: if the request was unsuccessful or an invalid
413422 compatibility level was returned
@@ -421,9 +430,7 @@ def get_compatibility(self, subject, headers=None):
421430 status .HTTP_200_OK <= code < status .HTTP_300_MULTIPLE_CHOICES
422431 )
423432 if not is_successful_request :
424- raise ClientError (
425- f"Unable to fetch compatibility level. Error code: { code } "
426- )
433+ raise ClientError (f"Unable to fetch compatibility level" )
427434
428435 compatibility = result .get ("compatibilityLevel" )
429436 if compatibility not in utils .VALID_LEVELS :
@@ -433,7 +440,7 @@ def get_compatibility(self, subject, headers=None):
433440 error_msg_suffix = str (compatibility )
434441 raise ClientError (
435442 f"Invalid compatibility level received: { error_msg_suffix } " ,
436- code ,
443+ http_code = code ,
437444 server_traceback = result ,
438445 )
439446
0 commit comments