Skip to content

Commit

Permalink
Merge pull request #587 from dronekit/tcr-please
Browse files Browse the repository at this point in the history
Catch and display message and attribute errors, then continue.
  • Loading branch information
peterbarker committed Mar 1, 2016
2 parents e836c57 + 2235c94 commit b201c51
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions dronekit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,20 @@ def notify_attribute_listeners(self, attr_name, value, cache=False):

# Notify observers.
for fn in self._attribute_listeners.get(attr_name, []):
fn(self, attr_name, value)
try:
fn(self, attr_name, value)
except Exception as e:
errprinter('>>> Exception in attribute handler for %s' %
attr_name)
errprinter('>>> ' + str(e))

for fn in self._attribute_listeners.get('*', []):
fn(self, attr_name, value)
try:
fn(self, attr_name, value)
except Exception as e:
errprinter('>>> Exception in attribute handler for %s' %
attr_name)
errprinter('>>> ' + str(e))

def on_attribute(self, name):
"""
Expand Down Expand Up @@ -1464,9 +1475,21 @@ def remove_message_listener(self, name, fn):

def notify_message_listeners(self, name, msg):
for fn in self._message_listeners.get(name, []):
fn(self, name, msg)
try:
fn(self, name, msg)
except Exception as e:
errprinter('>>> Exception in message handler for %s' %
msg.get_type())
errprinter('>>> ' + str(e))

for fn in self._message_listeners.get('*', []):
fn(self, name, msg)
try:
fn(self, name, msg)
except Exception as e:
errprinter('>>> Exception in message handler for %s' %
msg.get_type())
errprinter('>>> ' + str(e))


def close(self):
return self._handler.close()
Expand Down

0 comments on commit b201c51

Please sign in to comment.