Skip to content

Commit

Permalink
[engine] Report current module when error occurs
Browse files Browse the repository at this point in the history
Keep track of the latest updated module in the engine part, so that the
module causing an exception can be reported correctly.

fixes #110
  • Loading branch information
tobi-wan-kenobi committed Jun 10, 2017
1 parent dc06611 commit 7d13268
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bumblebee-status
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def main():
inp.stop()
sys.exit(0)
except BaseException as e:
module = engine.current_module()
logging.exception(e)
if output.started():
output.flush()
Expand All @@ -52,7 +53,7 @@ def main():
while True:
output.begin()
error = bumblebee.modules.error.Module(engine, config)
error.set("exception occurred: {}".format(e))
error.set("exception occurred: {} in {}".format(e, module))
widget = error.widgets()[0]
widget.link_module(error)
output.draw(widget, error)
Expand Down
5 changes: 5 additions & 0 deletions bumblebee/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def __init__(self, config, output=None, inp=None):
self.input = inp
self._aliases = self._read_aliases()
self.load_modules(config.modules())
self._current_module = None

self.input.register_callback(None, bumblebee.input.WHEEL_UP,
"i3-msg workspace prev_on_output")
Expand Down Expand Up @@ -145,12 +146,16 @@ def stop(self):
"""Stop the event loop"""
self._running = False

def current_module(self):
return self._current_module.__module__

def run(self):
"""Start the event loop"""
self._output.start()
while self.running():
self._output.begin()
for module in self._modules:
self._current_module = module
module.update(module.widgets())
for widget in module.widgets():
widget.link_module(module)
Expand Down

0 comments on commit 7d13268

Please sign in to comment.