[engine] Report current module when error occurs
Keep track of the latest updated module in the engine part, so that the module causing an exception can be reported correctly. fixes #110
This commit is contained in:
parent
dc06611fb1
commit
7d13268f66
2 changed files with 7 additions and 1 deletions
|
@ -42,6 +42,7 @@ def main():
|
||||||
inp.stop()
|
inp.stop()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
module = engine.current_module()
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
if output.started():
|
if output.started():
|
||||||
output.flush()
|
output.flush()
|
||||||
|
@ -52,7 +53,7 @@ def main():
|
||||||
while True:
|
while True:
|
||||||
output.begin()
|
output.begin()
|
||||||
error = bumblebee.modules.error.Module(engine, config)
|
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 = error.widgets()[0]
|
||||||
widget.link_module(error)
|
widget.link_module(error)
|
||||||
output.draw(widget, error)
|
output.draw(widget, error)
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Engine(object):
|
||||||
self.input = inp
|
self.input = inp
|
||||||
self._aliases = self._read_aliases()
|
self._aliases = self._read_aliases()
|
||||||
self.load_modules(config.modules())
|
self.load_modules(config.modules())
|
||||||
|
self._current_module = None
|
||||||
|
|
||||||
self.input.register_callback(None, bumblebee.input.WHEEL_UP,
|
self.input.register_callback(None, bumblebee.input.WHEEL_UP,
|
||||||
"i3-msg workspace prev_on_output")
|
"i3-msg workspace prev_on_output")
|
||||||
|
@ -145,12 +146,16 @@ class Engine(object):
|
||||||
"""Stop the event loop"""
|
"""Stop the event loop"""
|
||||||
self._running = False
|
self._running = False
|
||||||
|
|
||||||
|
def current_module(self):
|
||||||
|
return self._current_module.__module__
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Start the event loop"""
|
"""Start the event loop"""
|
||||||
self._output.start()
|
self._output.start()
|
||||||
while self.running():
|
while self.running():
|
||||||
self._output.begin()
|
self._output.begin()
|
||||||
for module in self._modules:
|
for module in self._modules:
|
||||||
|
self._current_module = module
|
||||||
module.update(module.widgets())
|
module.update(module.widgets())
|
||||||
for widget in module.widgets():
|
for widget in module.widgets():
|
||||||
widget.link_module(module)
|
widget.link_module(module)
|
||||||
|
|
Loading…
Reference in a new issue