From f7657610f412cb57a96d734d9e1b4af3fd189ee1 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 29 Mar 2017 19:42:44 +0200 Subject: [PATCH] jp (base): added msg and exit_code argument to errback so it's more generic --- frontends/src/jp/base.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontends/src/jp/base.py b/frontends/src/jp/base.py index d638ddf4..41b06e28 100644 --- a/frontends/src/jp/base.py +++ b/frontends/src/jp/base.py @@ -759,14 +759,19 @@ class CommandBase(object): raise exceptions.InternalError(_(u'trying to use output when use_output has not been set')) return self.host.output(output_type, self.args.output, self.extra_outputs, data) - def errback(self, failure_): + def errback(self, failure_, msg=None, exit_code=C.EXIT_ERROR): """generic callback for errbacks display failure_ then quit with generic error @param failure_: arguments returned by errback + @param msg(unicode, None): message template + use {} if you want to display failure message + @param exit_code(int): shell exit code """ - self.disp(u"error: {}".format(failure_), error=True) - self.host.quit(C.EXIT_ERROR) + if msg is None: + msg = _(u"error: {}") + self.disp(msg.format(failure_), error=True) + self.host.quit(exit_code) def add_parser_options(self): try: