diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-07-04 08:39:21 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-07-11 10:49:02 +0200 |
commit | 5f69a06d1a78242a65164a94d752380613e73e44 (patch) | |
tree | d80039d6dad813ac932cf20343a11298ade9208e /ipalib/plugins | |
parent | e494650b2cdb6ac7e1eda3da7cf03d4c36f2739a (diff) | |
download | freeipa-5f69a06d1a78242a65164a94d752380613e73e44.tar.gz freeipa-5f69a06d1a78242a65164a94d752380613e73e44.tar.xz freeipa-5f69a06d1a78242a65164a94d752380613e73e44.zip |
Fix batch command error reporting
The Batch command did not report errors correctly: it reported
the text of *all* errors, not just PublicError, used unicode(e)
instead of e.strerror (which results in incorrect i18n), and only
reported the text of error messages, not their type and code.
Fix these problems. Update tests.
https://fedorahosted.org/freeipa/ticket/2874
https://fedorahosted.org/freeipa/ticket/2901
Diffstat (limited to 'ipalib/plugins')
-rw-r--r-- | ipalib/plugins/batch.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ipalib/plugins/batch.py b/ipalib/plugins/batch.py index 8abad5e1e..db9c08f10 100644 --- a/ipalib/plugins/batch.py +++ b/ipalib/plugins/batch.py @@ -102,8 +102,6 @@ class batch(Command): ) result['error']=None except Exception, e: - result = dict() - result['error'] = unicode(e) if isinstance(e, errors.RequirementError) or \ isinstance(e, errors.CommandError): self.info( @@ -113,6 +111,15 @@ class batch(Command): self.info( '%s: batch: %s(%s): %s', context.principal, name, ', '.join(api.Command[name]._repr_iter(**params)), e.__class__.__name__ ) + if isinstance(e, errors.PublicError): + reported_error = e + else: + reported_error = errors.InternalError() + result = dict( + error=reported_error.strerror, + error_code=reported_error.errno, + error_name=unicode(type(reported_error).__name__), + ) results.append(result) return dict(count=len(results) , results=results) |