diff --git a/include/class_SnapshotHandler.inc b/include/class_SnapshotHandler.inc index 9bf318d5664a4c8506d2732afce7d320a86c1c5a..f119b43326b7c9e72cc53be2a85e43cd49f969d1 100644 --- a/include/class_SnapshotHandler.inc +++ b/include/class_SnapshotHandler.inc @@ -428,7 +428,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 3385aa0151b47d640aa02809e9a0a4765e82fc5b..044f87775fad3a758d41557b66d98bf2caa5a257 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..3e11f8310f8188ee6e07bd3b3faf38a8efba7876 --- /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 Class LDAP + */ + +/*! \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_ldap.inc b/include/class_ldap.inc index 8082a5a056192079bf06a5cda6f164f40dd9cea1..56bc1d1680ad0b74106888e35d39630bc1cb874a 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -28,11 +28,6 @@ define("SPECIALS_OVERRIDE", FALSE); -/*! \class LdapGeneralizedTimeBadFormatException - \brief Exception class which can be thrown by LDAP if the LDIF format is broken -*/ -class LDIFImportException extends Exception {} - /*! * \brief This class contains all ldap function needed to make * ldap operations easy 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 dc753a5fc00fe9a3bbbff9cd7fd417750fc2a268..d8db92bd0f1cd1a41a2ac661284024224b837f9e 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -19,12 +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 NoManagementClassException extends Exception {}; -class LDAPFailureException extends Exception {}; - class objects { /*! diff --git a/include/class_plugin.inc b/include/class_plugin.inc index a8684b7175ae1d381cea0187be7b327c2964e952..6f105e5f792168cc339ca625652943c6ea63a489 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 b120d06913719f4838262006bbf6d619094051d0..d4cae9a7c3fc1163e3abeb4cfb8b13e8ff299848 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -3059,7 +3059,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/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index 11bcc5021f207c5e642d767c3658dacb76f055bd..171c6b47eb42c18c4a62f6e8b0e2f4bc5b996ba7 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -1055,7 +1055,7 @@ class simplePlugin extends plugin ); try { $refs[$dn]['link'] = objects::link($dn, $objectType); - } catch (Exception $e) { + } catch (FusionDirectoryException $e) { trigger_error("Could not create link to $dn: ".$e->getMessage()); $refs[$dn]['link'] = $dn; } @@ -1067,7 +1067,7 @@ class simplePlugin extends plugin ); try { $refs[$dn]['tabs'][$tab]['link'] = objects::link($dn, $objectType, "tab_$tab", sprintf(_('Tab "%s"'), $tab_infos['name'])); - } catch (Exception $e) { + } catch (FusionDirectoryException $e) { trigger_error("Could not create link to $dn $tab: ".$e->getMessage()); $refs[$dn]['tabs'][$tab]['link'] = $tab; } diff --git a/plugins/addons/dashboard/class_dashBoard.inc b/plugins/addons/dashboard/class_dashBoard.inc index cb89b3eff2b15c3964874f01522c941c7450baad..9b250f7caec61b56281d93023c247b0cd3f0f0fe 100644 --- a/plugins/addons/dashboard/class_dashBoard.inc +++ b/plugins/addons/dashboard/class_dashBoard.inc @@ -67,7 +67,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 83c4253be40bac63e3266afde39b916637e7a69a..c875bc42aaa9f934fe4c0c0f2ab9be23607f5482 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;