gaphor/generic

Errors out badly if no handler registered for an event class.

riccardomurri opened this issue · 1 comments

If an event is fire'd before any handler is subscribed to the event's class, generic.event.fire() dies with a traceback that ends like this::

Traceback (most recent call last):
  ...
  File ".../site-packages/gc3libs/__init__.py", line 1939, in fset
    fire(TaskStateChange(self._ref, self._state, value))
  File ".../site-packages/generic/event.py", line 77, in fire
    for handler in handler_set.all_handlers:
AttributeError: 'NoneType' object has no attribute 'all_handlers'

It's debatable that firing an event when there is no one to handle it
is an error (doing nothing is perfectly good semantics) -- still,
generic.event should at least give a sensible error message and
possibly raise a relevant error class (e.g., generic.event.NoRegisteredHandler)