jp (base): added generic errback to CommandBase + show error message on plugin ImportError

This commit is contained in:
Goffi 2017-03-09 23:09:18 +01:00
commit 90824a69b0

View file

@ -332,8 +332,10 @@ class Jp(object):
try:
module = import_module(module_path)
self.import_plugin_module(module, type_)
except ImportError:
log.warning(_(u"Can't import {} plugin, ignoring it".format(module_path)))
except ImportError as e:
log.warning(_(u"Can't import {module_path} plugin, ignoring it: {msg}".format(
module_path = module_path,
msg = e)))
except exceptions.CancelError:
continue
except exceptions.MissingModule as e:
@ -724,6 +726,15 @@ class CommandBase(object):
def output(self, data):
return self.host.output(self._output_type, self.args.output, self.extra_outputs, data)
def errback(self, failure_):
"""generic callback for errbacks
display failure_ then quit with generic error
@param failure_: arguments returned by errback
"""
self.disp(u"error: {}".format(failure_), error=True)
self.host.quit(C.EXIT_ERROR)
def add_parser_options(self):
try:
subcommands = self.subcommands