Skip to content

Commit

Permalink
Merge pull request #43 from astronomy-commons/error_visibility
Browse files Browse the repository at this point in the history
Expose low-level Kafka error details through KafkaException
  • Loading branch information
spenczar authored Jun 3, 2021
2 parents 4e489f8 + 832f717 commit 739199b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions adc/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ def raise_delivery_errors(kafka_error: confluent_kafka.KafkaError,
class KafkaException(Exception):
@classmethod
def from_kafka_error(cls, error):
return cls(error.name(), error.str())

def __init__(self, name, message):
self.name = name
self.message = message
msg = f"Error communicating with Kafka: code={name} {message}"
return cls(error)

def __init__(self, error):
self.error = error
self.name = error.name()
self.reason = error.str()
self.retriable = error.retriable()
self.fatal = error.fatal()
msg = f"Error communicating with Kafka: code={self.name} {self.reason}"
super(KafkaException, self).__init__(msg)

0 comments on commit 739199b

Please sign in to comment.