From 83bb41faebc0a61269f2869e9123166254fff5b3 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 8 Oct 2008 23:31:49 -0400 Subject: Mechanism to convert from xmlrpclib.Fault to an IPAError exception Include slew of new exceptions, not all of which are used yet --- ipa_server/ipaldap.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'ipa_server/ipaldap.py') diff --git a/ipa_server/ipaldap.py b/ipa_server/ipaldap.py index 7ee31465..a7604021 100644 --- a/ipa_server/ipaldap.py +++ b/ipa_server/ipaldap.py @@ -32,7 +32,7 @@ import ldap.sasl from ldap.controls import LDAPControl,DecodeControlTuples,EncodeControlTuples from ldap.ldapobject import SimpleLDAPObject from ipa_server import ipautil - +from ipalib import errors # Global variable to define SASL auth sasl_auth = ldap.sasl.sasl({},'GSSAPI') @@ -279,12 +279,12 @@ class IPAdmin(SimpleLDAPObject): res = self.search(*args) objtype, obj = self.result(res) except ldap.NO_SUCH_OBJECT, e: - raise e + raise errors.NotFound, notfound(args) except ldap.LDAPError, e: - raise e + raise errors.DatabaseError, e if not obj: - raise ldap.NO_SUCH_OBJECT + raise errors.NotFound, notfound(args) elif isinstance(obj,Entry): return obj @@ -308,7 +308,7 @@ class IPAdmin(SimpleLDAPObject): raise e if not obj: - raise ldap.NO_SUCH_OBJECT + raise errors.NotFound, notfound(args) entries = [] for s in obj: @@ -345,7 +345,7 @@ class IPAdmin(SimpleLDAPObject): raise e if not entries: - raise ldap.NO_SUCH_OBJECT + raise errors.NotFound, notfound(args) if partial == 1: counter = -1 @@ -408,10 +408,9 @@ class IPAdmin(SimpleLDAPObject): # it indicates the previous attribute was removed by another # update, making the oldentry stale. except ldap.NO_SUCH_ATTRIBUTE: - # FIXME: better error - raise SyntaxError("mid-air collision") + raise ipaldap.MidairCollision except ldap.LDAPError, e: - raise e + raise ipaldap.DatabaseError, e return True def generateModList(self, old_entry, new_entry): -- cgit