From 6fc1f1bc71ed22e9013a279cf8f9297e44bd8841 Mon Sep 17 00:00:00 2001 From: Benoit Mortier <benoit.mortier@opensides.be> Date: Sat, 31 Dec 2016 14:21:06 +0100 Subject: [PATCH] Fixes: #5098 Exception should be reorganized Adapted to the new exception class Signed-off-by: Benoit Mortier <benoit.mortier@opensides.be> --- include/class_IconTheme.inc | 5 +++-- include/class_ldap.inc | 14 ++++++-------- include/class_objects.inc | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/class_IconTheme.inc b/include/class_IconTheme.inc index 1d10ed5de..c48df8da3 100644 --- a/include/class_IconTheme.inc +++ b/include/class_IconTheme.inc @@ -83,7 +83,7 @@ class IconTheme $this->path = $folder; $datas = @parse_ini_file($folder.'/index.theme', TRUE, INI_SCANNER_RAW); if ($datas === FALSE) { - throw new Exception('Error while parsing theme file'); + throw new ThemeFileParsingException('Error while parsing theme file'); } if (isset($datas['Icon Theme']['Directories']) && !empty($datas['Icon Theme']['Directories'])) { $dirs = preg_split('/,/', $datas['Icon Theme']['Directories']); @@ -186,7 +186,8 @@ class IconTheme } else { $themes[$file] = new IconTheme("$path/$file", static::$default_theme); } - } catch (Exception $e) { + } catch (ThemeFileParsingException $e) { + continue; } } } diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 41ce97550..c12693dcc 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -1135,7 +1135,7 @@ class LDAP foreach ($fileLines as $lineNumber => $fileLine) { if (preg_match('/^ /', $fileLine)) { if ($line === NULL) { - throw new Exception(sprintf(_('Error line %s, first line of an entry cannot start with a space'), $lineNumber)); + throw new LDIFImportException(sprintf(_('Error line %s, first line of an entry cannot start with a space'), $lineNumber)); } /* Append to current line */ $line .= substr($fileLine, 1); @@ -1153,19 +1153,19 @@ class LDAP $value = base64_decode(trim(substr($value, 1))); } if (preg_match('/^</', $value)) { - throw new Exception(sprintf(_('Error line %s, references to an external file are not supported'), $lineNumber)); + throw new LDIFImportException(sprintf(_('Error line %s, references to an external file are not supported'), $lineNumber)); } if ($value === '') { - throw new Exception(sprintf(_('Error line %s, attribute "%s" has no value'), $lineNumber, $key)); + throw new LDIFImportException(sprintf(_('Error line %s, attribute "%s" has no value'), $lineNumber, $key)); } if ($key == 'dn') { if (!empty($entry)) { - throw new Exception(sprintf(_('Error line %s, an entry bloc can only have one dn'), $lineNumber)); + throw new LDIFImportException(sprintf(_('Error line %s, an entry bloc can only have one dn'), $lineNumber)); } $entry['dn'] = $value; $entryStart = $lineNumber; } elseif (empty($entry)) { - throw new Exception(sprintf(_('Error line %s, an entry bloc should start with the dn'), $lineNumber)); + throw new LDIFImportException(sprintf(_('Error line %s, an entry bloc should start with the dn'), $lineNumber)); } else { if (!isset($entry[$key])) { $entry[$key] = array(); @@ -1196,9 +1196,7 @@ class LDAP /* If we can't Import, return with a file error */ if (!$this->import_single_entry($srp, $entry, $usemodify, $usermdir)) { - $error = sprintf(_("Error while importing dn: '%s', please check your LDIF from line %s on!"), $entry['dn'][0], - $startLine); - throw new Exception($error); + throw new LDIFImportException(sprintf(_('Error while importing dn: "%s", please check your LDIF from line %s on!'), $entry['dn'][0], $startLine)); } } } diff --git a/include/class_objects.inc b/include/class_objects.inc index 2c9e96ea5..e4dc00620 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -159,7 +159,7 @@ class objects $infos = static::infos($type); 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']); $index = $pInfos['INDEX']; @@ -179,7 +179,7 @@ class objects $text = $dn; } } else { - throw new Exception('Dn '.$dn.' not found in LDAP'); + throw new NonExistingLdapNodeException('Dn '.$dn.' not found in LDAP'); } } elseif (is_array($text)) { $text = $text[$infos['nameAttr']][0]; -- GitLab