From d53218a9321eb4def0bfeb484709323de74eef1a Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mon, 3 Nov 2008 17:19:29 -0500 Subject: Handle exceptions in the command-line instead of in the XMLRPC client plugin --- ipalib/cli.py | 10 ++++++++++ ipalib/plugins/b_xmlrpc.py | 9 +-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ipalib/cli.py b/ipalib/cli.py index 732e38bb..8cf8d304 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -377,6 +377,16 @@ class CLI(object): if callable(cmd.output_for_cli): cmd.output_for_cli(ret) return 0 + except errors.GenericError, err: + code = getattr(err,'faultCode',None) + faultString = getattr(err,'faultString',None) + if not code: + raise err + if code < errors.IPA_ERROR_BASE: + print "%s: %s" % (code, faultString) + else: + print "%s: %s" % (code, getattr(err,'__doc__','')) + return 1 except StandardError, e: print e return 2 diff --git a/ipalib/plugins/b_xmlrpc.py b/ipalib/plugins/b_xmlrpc.py index 2c98fb8a..9c6af0a0 100644 --- a/ipalib/plugins/b_xmlrpc.py +++ b/ipalib/plugins/b_xmlrpc.py @@ -64,14 +64,7 @@ class xmlrpc(Backend): print e[1] except xmlrpclib.Fault, e: err = errors.convertFault(e) - code = getattr(err,'faultCode',None) - faultString = getattr(err,'faultString',None) - if not code: - raise err - if code < errors.IPA_ERROR_BASE: - print "%s: %s" % (code, faultString) - else: - print "%s: %s" % (code, getattr(err,'__doc__','')) + raise err return api.register(xmlrpc) -- cgit