Slight change to how exceptions are handled

This commit is contained in:
Rob Crittenden
2008-10-09 01:43:23 -04:00
parent 83bb41faeb
commit 5c07d97865
2 changed files with 3 additions and 4 deletions

View File

@@ -365,8 +365,7 @@ class IPAdmin(SimpleLDAPObject):
self.set_option(ldap.OPT_SERVER_CONTROLS, sctrl)
self.add_s(*args)
except ldap.ALREADY_EXISTS, e:
# duplicate value
raise e
raise errors.DuplicateEntry, "Entry already exists"
except ldap.LDAPError, e:
raise e
return True

View File

@@ -266,7 +266,7 @@ class NotFound(GenericError):
"""Entry not found"""
faultCode = 1003
class Duplicate(GenericError):
class DuplicateEntry(GenericError):
"""This entry already exists"""
faultCode = 1004
@@ -349,7 +349,7 @@ def convertFault(fault):
return fault
for v in globals().values():
if type(v) == type(Exception) and issubclass(v,GenericError) and \
code == getattr(v,'faultCode',None):
code == getattr(v,'faultCode',None):
ret = v(fault.faultString)
ret.fromFault = True
return ret