Skip to content

Commit

Permalink
added ZKConnectError so we're not bubbling exceptions from zc.zk
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ormsbee committed Dec 15, 2011
1 parent 1d070bd commit af353eb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions brod/zk.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from itertools import chain

import zookeeper
from zc.zk import ZooKeeper
from zc.zk import ZooKeeper, FailedConnect

from brod.base import BrokerPartition, FetchResult, KafkaError, MessageSet
from brod.blocking import Kafka
Expand All @@ -23,6 +23,7 @@

class NoAvailablePartitionsError(KafkaError): pass
class ConsumerEntryNotFoundError(KafkaError): pass
class ZKConnectError(KafkaError): pass

class ZKUtil(object):

Expand All @@ -31,7 +32,10 @@ class ZKUtil(object):

"""Abstracts all Kafka-specific ZooKeeper access."""
def __init__(self, zk_conn_str):
self._zk = ZooKeeper(zk_conn_str)
try:
self._zk = ZooKeeper(zk_conn_str)
except FailedConnect as e:
raise ZKConnectError(e)

def close(self):
self._zk.close()
Expand Down

0 comments on commit af353eb

Please sign in to comment.