diff --git a/include/class_SnapshotHandler.inc b/include/class_SnapshotHandler.inc index 8d1dece318e2bcf565c6a13b6a50c385ca93d8ad..954d95fee2dd3ba257ed2d92b812da57b876eadb 100644 --- a/include/class_SnapshotHandler.inc +++ b/include/class_SnapshotHandler.inc @@ -459,7 +459,7 @@ class SnapshotHandler if (!$ldap->success()) { msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, "", get_class()), LDAP_ERROR); } - } catch (Exception $e) { + } catch (LDIFImportException $e) { msg_dialog::display(_('LDAP error'), $e->getMessage(), ERROR_DIALOG); } } diff --git a/include/class_config.inc b/include/class_config.inc index cb1f6c6595f89d45558aeb7e89eb26d43043414a..444318dcb407623a4913cfb17c7ac8062a385c6c 100644 --- a/include/class_config.inc +++ b/include/class_config.inc @@ -275,7 +275,7 @@ class config { try { $cache[$creds] = cred_decrypt($creds, $_SERVER['HTTP_FDKEY']); session::global_set('HTTP_FDKEY_CACHE', $cache); - } catch (Exception $e) { + } catch (FusionDirectoryException $e) { $msg = sprintf( _('It seems you are trying to decode something which is not encoded : %s<br/>'."\n". 'Please check you are not using a fusiondirectory.secrets file while your passwords are not encrypted.'), diff --git a/include/class_exceptions.inc b/include/class_exceptions.inc new file mode 100644 index 0000000000000000000000000000000000000000..7bbb356c97a03335f76135722e8784be71524e8b --- /dev/null +++ b/include/class_exceptions.inc @@ -0,0 +1,46 @@ +<?php +/* + This code is part of FusionDirectory (http://www.fusiondirectory.org/) + Copyright (C) 2015-2016 FusionDirectory + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +/*! + * \file class_exceptions.inc + * Source code for FusionDirectory exceptions + */ + +/*! \class FusionDirectoryException + \brief Parent class for all exceptions thrown in FusionDirectory +*/ +class FusionDirectoryException extends Exception {} + +/*! \class LDIFImportException + \brief Exception class which can be thrown by LDAP if the LDIF format is broken +*/ +class LDIFImportException extends FusionDirectoryException {} + +/*! \class LdapGeneralizedTimeBadFormatException + \brief Exception class which can be thrown by LdapGeneralizedTime if the format does not match +*/ +class LdapGeneralizedTimeBadFormatException extends FusionDirectoryException {} + +class NonExistingObjectTypeException extends FusionDirectoryException {} +class NonExistingBranchException extends FusionDirectoryException {} +class NonExistingLdapNodeException extends FusionDirectoryException {} +class EmptyFilterException extends FusionDirectoryException {} +class NoManagementClassException extends FusionDirectoryException {} +class LDAPFailureException extends FusionDirectoryException {} diff --git a/include/class_ldapGeneralizedTime.inc b/include/class_ldapGeneralizedTime.inc index 42effea1261b161d13b6cf692f9d56ac25905146..0a1e7c662034045e0be703de0eb16c9f65d343f8 100644 --- a/include/class_ldapGeneralizedTime.inc +++ b/include/class_ldapGeneralizedTime.inc @@ -32,11 +32,6 @@ '19941216101255,5Z' */ -/*! \class LdapGeneralizedTimeBadFormatException - \brief Exception class which can be thrown by LdapGeneralizedTime if the format does not match -*/ -class LdapGeneralizedTimeBadFormatException extends Exception {}; - /*! \class LdapGeneralizedTime \brief LdapGeneralizedTime allows you to convert from and to LDAPĂ‚ GeneralizedTime format PHP DateTime objects diff --git a/include/class_objects.inc b/include/class_objects.inc index 6019aa122f5b1272a290c4599fd6990db58ac866..2c9e96ea58bf39e4ca6cf5176f96a21cbc55830d 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -19,10 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ -class NonExistingObjectTypeException extends Exception {} -class NonExistingBranchException extends Exception {} -class EmptyFilterException extends Exception {} - class objects { /*! diff --git a/include/class_plugin.inc b/include/class_plugin.inc index b77085fb4c10facc15324c52c260b7bbb5998832..ae9e550f16be5f33b81ff6ebf979e46f314c3594 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ -class NonExistingLdapNodeException extends Exception {} - /*! * \file class_plugin.inc * Source code for the class plugin diff --git a/include/functions.inc b/include/functions.inc index a5b57336bbd178847e95734c070119b840215699..6a22ebfa934838b62bb33ca43089db6ae58a3bb9 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -3022,7 +3022,7 @@ function cred_decrypt($input, $password) /************************* Inspired by Crypt/CBC.pm *******************************/ $input = pack('H*', $input); if (substr($input, 0, 8) != 'Salted__') { - throw new Exception("Invalid hash header: expected 'Salted__', found '".substr($input, 0, 8)."'"); + throw new FusionDirectoryException("Invalid hash header: expected 'Salted__', found '".substr($input, 0, 8)."'"); } $salt = substr($input, 8, 8); $input = substr($input, 16); diff --git a/plugins/addons/dashboard/class_dashBoard.inc b/plugins/addons/dashboard/class_dashBoard.inc index 21a24d48ea77bfa3c20fbff1ff01bb343aabc181..56e0eba91fb9b010bdde0eb743252d40a8f3b72e 100644 --- a/plugins/addons/dashboard/class_dashBoard.inc +++ b/plugins/addons/dashboard/class_dashBoard.inc @@ -68,7 +68,7 @@ class dashboard extends simplePlugin foreach ($config->data['OBJECTS'] as $type => $infos) { try { $nb = objects::count($type); - } catch (Exception $e) { + } catch (FusionDirectoryException $e) { $nb = 0; trigger_error("Problem with $type:".$e->getMessage()); } diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc index 02d6f68c0a5ef56e00fcb92ae40af1b2370f97ec..b7f27772c73d4f5e060fb877f94b1049c12decac 100644 --- a/setup/class_setupStep_Migrate.inc +++ b/setup/class_setupStep_Migrate.inc @@ -44,7 +44,7 @@ array_to_ldif - Create ldif output of an ldap result array ****************/ -class CheckFailedException extends Exception +class CheckFailedException extends FusionDirectoryException { private $error;