Commit 27aaa535 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Using custom exceptions in class_objects.inc as well

Showing with 5 additions and 3 deletions
+5 -3
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
class NonExistingObjectTypeException extends Exception {}; class NonExistingObjectTypeException extends Exception {};
class NonExistingBranchException extends Exception {}; class NonExistingBranchException extends Exception {};
class EmptyFilterException extends Exception {}; class EmptyFilterException extends Exception {};
class NoManagementClassException extends Exception {};
class LDAPFailureException extends Exception {};
class objects class objects
{ {
...@@ -131,7 +133,7 @@ class objects ...@@ -131,7 +133,7 @@ class objects
$ldap->cd($ou); $ldap->cd($ou);
$ldap->search($filter, $search_attrs); $ldap->search($filter, $search_attrs);
if (!$ldap->success()) { if (!$ldap->success()) {
throw new Exception($ldap->get_error()); throw new LDAPFailureException($ldap->get_error());
} }
return $ldap; return $ldap;
} }
...@@ -164,7 +166,7 @@ class objects ...@@ -164,7 +166,7 @@ class objects
$infos = static::infos($type); $infos = static::infos($type);
if (!isset($infos['management'])) { if (!isset($infos['management'])) {
throw new Exception('Asked for link for type "'.$type.'" but it does not have a management class'); throw new NoManagementClassException('Asked for link for type "'.$type.'" but it does not have a management class');
} }
$pInfos = pluglist::pluginInfos($infos['management']); $pInfos = pluglist::pluginInfos($infos['management']);
$index = $pInfos['INDEX']; $index = $pInfos['INDEX'];
...@@ -184,7 +186,7 @@ class objects ...@@ -184,7 +186,7 @@ class objects
$text = $dn; $text = $dn;
} }
} else { } else {
throw new Exception('Dn '.$dn.' not found in LDAP'); throw new NonExistingLdapNodeException('Dn '.$dn.' not found in LDAP');
} }
} elseif (is_array($text)) { } elseif (is_array($text)) {
$text = $text[$infos['nameAttr']][0]; $text = $text[$infos['nameAttr']][0];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment