changeset 2178:b9bfc45cea22

jp (base): added generic errback to CommandBase + show error message on plugin ImportError
author Goffi <goffi@goffi.org>
date Thu, 09 Mar 2017 23:09:18 +0100
parents 09cfec4d8d19
children e42c6c131b52
files frontends/src/jp/base.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/base.py	Thu Mar 09 23:07:38 2017 +0100
+++ b/frontends/src/jp/base.py	Thu Mar 09 23:09:18 2017 +0100
@@ -332,8 +332,10 @@
                 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 @@
     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