Skip to content

Commit 9b65c83

Browse files
committed
Merge pull request #3 from mikeSimonson/invalid-yml
Throwing exception when the configuration cannot be parsed properly.
2 parents 349740d + e937b2b commit 9b65c83

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Dflydev/DotAccessConfiguration/YamlConfigurationBuilder.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Dflydev\DotAccessConfiguration;
1313

14+
use Psr\Log\InvalidArgumentException;
1415
use Symfony\Component\Yaml\Yaml;
1516

1617
class YamlConfigurationBuilder extends AbstractConfigurationBuilder
@@ -38,7 +39,16 @@ public function __construct($input = null)
3839
public function internalBuild(ConfigurationInterface $configuration)
3940
{
4041
if (null !== $this->input) {
41-
$configuration->importRaw(Yaml::parse($this->input));
42+
try{
43+
$yml = Yaml::parse($this->input, true);
44+
} catch (\Exception $e) {
45+
throw new InvalidArgumentException($e->getMessage(), 0, $e);
46+
}
47+
if (is_string($yml))
48+
{
49+
throw(new \InvalidArgumentException('Yaml could not be parsed, parser detected a string.'));
50+
}
51+
$configuration->importRaw($yml);
4252
}
4353
}
4454
}

0 commit comments

Comments
 (0)