Merge pull request #3291 from Icinga/bugfix/ini-parser-hides-file-location-3252

IniParser: include the file location in parsing exceptions
This commit is contained in:
lippserd 2018-01-19 13:22:28 +01:00 committed by GitHub
commit d25e7b84eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\File\Ini; namespace Icinga\File\Ini;
use ErrorException;
use Icinga\File\Ini\Dom\Section; use Icinga\File\Ini\Dom\Section;
use Icinga\File\Ini\Dom\Comment; use Icinga\File\Ini\Dom\Comment;
use Icinga\File\Ini\Dom\Document; use Icinga\File\Ini\Dom\Document;
@ -260,6 +261,12 @@ class IniParser
throw new NotReadableError('Couldn\'t read the file `%s\'', $path); 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);
} }
} }