Mercurial > libervia-backend
changeset 2213:1010054cf771
jp (base): added msg and exit_code argument to errback so it's more generic
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 29 Mar 2017 19:42:44 +0200 |
parents | eaf2467d19ce |
children | 4e06cd44e667 |
files | frontends/src/jp/base.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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: