# HG changeset patch # User Goffi # Date 1490809364 -7200 # Node ID 1010054cf771b2d836ad6f4b7c891d558cc36afe # Parent eaf2467d19ce4796a5320d0fa02cf7f688bbe4c8 jp (base): added msg and exit_code argument to errback so it's more generic diff -r eaf2467d19ce -r 1010054cf771 frontends/src/jp/base.py --- a/frontends/src/jp/base.py Wed Mar 29 19:42:42 2017 +0200 +++ b/frontends/src/jp/base.py Wed Mar 29 19:42:44 2017 +0200 @@ -759,14 +759,19 @@ 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: