Catch all exceptions.
This commit is contained in:
parent
458e05cae8
commit
328eb92864
@ -9,6 +9,7 @@ from i3pystatus.core.imputil import ClassFinder
|
|||||||
from i3pystatus.core.modules import Module
|
from i3pystatus.core.modules import Module
|
||||||
|
|
||||||
DEFAULT_LOG_FORMAT = '%(asctime)s [%(levelname)-8s][%(name)s %(lineno)d] %(message)s'
|
DEFAULT_LOG_FORMAT = '%(asctime)s [%(levelname)-8s][%(name)s %(lineno)d] %(message)s'
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CommandEndpoint:
|
class CommandEndpoint:
|
||||||
@ -106,26 +107,12 @@ class Status:
|
|||||||
if not module:
|
if not module:
|
||||||
return
|
return
|
||||||
|
|
||||||
err_colour = "#FF0000"
|
|
||||||
try:
|
try:
|
||||||
return self.modules.append(module, *args, **kwargs)
|
return self.modules.append(module, *args, **kwargs)
|
||||||
except ImportError as import_error:
|
|
||||||
if import_error.name and not import_error.path and isinstance(module, str):
|
|
||||||
# This is a package/module not found exception raised by importing a module on-the-fly
|
|
||||||
return self.modules.append(Text(
|
|
||||||
color=err_colour,
|
|
||||||
text="{i3py_mod}: Missing Python module '{missing_module}'".format(
|
|
||||||
i3py_mod=module,
|
|
||||||
missing_module=import_error.name)))
|
|
||||||
else:
|
|
||||||
raise import_error
|
|
||||||
except ConfigError as configuration_error:
|
|
||||||
return self.modules.append(Text(
|
|
||||||
color=err_colour,
|
|
||||||
text=configuration_error.message))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
log.exception(e)
|
||||||
return self.modules.append(Text(
|
return self.modules.append(Text(
|
||||||
color=err_colour,
|
color="#FF0000",
|
||||||
text="{i3py_mod}: Fatal Error - {ex}({msg})".format(
|
text="{i3py_mod}: Fatal Error - {ex}({msg})".format(
|
||||||
i3py_mod=module,
|
i3py_mod=module,
|
||||||
ex=e.__class__.__name__,
|
ex=e.__class__.__name__,
|
||||||
|
Loading…
Reference in New Issue
Block a user