The package throws a single exception type:
InitPHP\ParameterBag\Exception\ParameterBagInvalidArgumentException.
It extends \InvalidArgumentException, so catch (\InvalidArgumentException $e) blocks continue to work.
| Trigger | Example |
|---|---|
| Unknown option key in the constructor | new ParameterBag([], ['is_multi' => true]); |
Non-array, non-ParameterBag argument to merge() |
$bag->merge('string'); |
Array-access append ($bag[] = $value) |
$bag[] = 'value'; |
use InitPHP\ParameterBag\Exception\ParameterBagInvalidArgumentException;
use InitPHP\ParameterBag\ParameterBag;
try {
$bag = new ParameterBag([], ['seperator' => '|']);
} catch (ParameterBagInvalidArgumentException $e) {
// Handle the typo.
}InvalidArgumentException
└── InitPHP\ParameterBag\Exception\ParameterBagInvalidArgumentException
If you wrap the package in your own service layer and want callers to catch a single, domain-specific type, re-throw the exception as a subclass of your own.