diff options
author | Rob Crittenden <rcritten@redhat.com> | 2009-05-08 11:15:45 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-05-13 14:16:44 -0400 |
commit | 1c31b5bc08a2f4bc55678c69eb67508122480906 (patch) | |
tree | 0166354ab5bb1e8bb4b664efab23bb86e770556a /ipaserver | |
parent | de88954b91f49387421f68a056a2e12cb6e94e7e (diff) | |
download | freeipa-1c31b5bc08a2f4bc55678c69eb67508122480906.tar.gz freeipa-1c31b5bc08a2f4bc55678c69eb67508122480906.tar.xz freeipa-1c31b5bc08a2f4bc55678c69eb67508122480906.zip |
Add a reason to the NotFound exception so we can provide more robust errors
Diffstat (limited to 'ipaserver')
-rw-r--r-- | ipaserver/ipaldap.py | 8 | ||||
-rw-r--r-- | ipaserver/servercore.py | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/ipaserver/ipaldap.py b/ipaserver/ipaldap.py index c80cda428..d60e23fd6 100644 --- a/ipaserver/ipaldap.py +++ b/ipaserver/ipaldap.py @@ -298,7 +298,7 @@ class IPAdmin(SimpleLDAPObject): raise e except ldap.NO_SUCH_OBJECT, e: args = kw.get('args', '') - raise errors.NotFound(msg=notfound(args)) + raise errors.NotFound(reason=notfound(args)) except ldap.ALREADY_EXISTS, e: raise errors.DuplicateEntry() except ldap.CONSTRAINT_VIOLATION, e: @@ -361,7 +361,7 @@ class IPAdmin(SimpleLDAPObject): self.__handle_errors(e, **kw) if not obj: - raise errors.NotFound(msg=notfound(args)) + raise errors.NotFound(reason=notfound(args)) elif isinstance(obj,Entry): return obj @@ -383,7 +383,7 @@ class IPAdmin(SimpleLDAPObject): self.__handle_errors(e, **kw) if not obj: - raise errors.NotFound(msg=notfound(args)) + raise errors.NotFound(reason=notfound(args)) entries = [] for s in obj: @@ -421,7 +421,7 @@ class IPAdmin(SimpleLDAPObject): self.__handle_errors(e, **kw) if not entries: - raise errors.NotFound(msg=notfound(args)) + raise errors.NotFound(reason=notfound(args)) if partial == 1: counter = -1 diff --git a/ipaserver/servercore.py b/ipaserver/servercore.py index 1e0972d7b..74014c758 100644 --- a/ipaserver/servercore.py +++ b/ipaserver/servercore.py @@ -270,7 +270,7 @@ def search(base, filter, attributes, timelimit=1, sizelimit=3000, scope=ldap.SCO results = context.ldap.conn.getListAsync(base, scope, filter, attributes, 0, None, None, timelimit, sizelimit) except ldap.NO_SUCH_OBJECT: - raise errors.NotFound() + raise errors.NotFound(reason=filter) counter = results[0] entries = [counter] @@ -315,9 +315,9 @@ def get_ipa_config(): searchfilter = "cn=ipaconfig" try: config = get_sub_entry("cn=etc," + api.env.basedn, searchfilter) - except ldap.NO_SUCH_OBJECT, e: + except ldap.NO_SUCH_OBJECT: # FIXME - raise errors.NotFound() + raise errors.NotFound(reason="IPA configuration cannot be loaded") return config @@ -409,12 +409,12 @@ def add_member_to_group(member_dn, group_dn, memberattr='member'): group = get_entry_by_dn(group_dn, None) if group is None: - raise errors.NotFound() + raise errors.NotFound(reason="cannot find group %s" % group_dn) # check to make sure member_dn exists member_entry = get_base_entry(member_dn, "(objectClass=*)", ['dn','objectclass']) if not member_entry: - raise errors.NotFound() + raise errors.NotFound(reason="cannot find member %s" % member_dn) # Add the new member to the group member attribute members = group.get(memberattr, []) @@ -430,7 +430,7 @@ def remove_member_from_group(member_dn, group_dn, memberattr='member'): group = get_entry_by_dn(group_dn, None) if group is None: - raise errors.NotFound() + raise errors.NotFound(reason="cannot find group %s" % group_dn) """ if group.get('cn') == "admins": member = get_entry_by_dn(member_dn, ['dn','uid']) |