From 5616e9d508d413a07dc7fb80a19b49b7d80e53e6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 19 Jan 2018 09:47:15 +0100 Subject: [PATCH] IniParser: include the file location in parsing exceptions refs #3252 --- library/Icinga/File/Ini/IniParser.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/Icinga/File/Ini/IniParser.php b/library/Icinga/File/Ini/IniParser.php index 4ad760ee9..2453d81c9 100644 --- a/library/Icinga/File/Ini/IniParser.php +++ b/library/Icinga/File/Ini/IniParser.php @@ -3,6 +3,7 @@ namespace Icinga\File\Ini; +use ErrorException; use Icinga\File\Ini\Dom\Section; use Icinga\File\Ini\Dom\Comment; use Icinga\File\Ini\Dom\Document; @@ -260,6 +261,12 @@ class IniParser throw new NotReadableError('Couldn\'t read the file `%s\'', $path); } - return Config::fromArray(parse_ini_string($content, true))->setConfigFile($file); + try { + $configArray = parse_ini_string($content, true); + } catch (ErrorException $e) { + throw new ConfigurationError('Couldn\'t parse the INI file `%s\'', $path, $e); + } + + return Config::fromArray($configArray)->setConfigFile($file); } }