Throw AlreadyExistsException instead of InvalidArgumentException in RoleForm::add()
This commit is contained in:
parent
2e970b2965
commit
1135643fe1
|
@ -3,6 +3,7 @@
|
|||
|
||||
namespace Icinga\Forms\Security;
|
||||
|
||||
use Icinga\Exception\AlreadyExistsException;
|
||||
use Icinga\Exception\NotFoundError;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
|
@ -204,7 +205,7 @@ class RoleForm extends ConfigForm
|
|||
* @return $this
|
||||
*
|
||||
* @throws LogicException If the config is not set
|
||||
* @throws InvalidArgumentException If the role to add already exists
|
||||
* @throws AlreadyExistsException If the role to add already exists
|
||||
* @see ConfigForm::setConfig() For setting the config.
|
||||
*/
|
||||
public function add($name, array $values)
|
||||
|
@ -213,10 +214,10 @@ class RoleForm extends ConfigForm
|
|||
throw new LogicException(sprintf('Can\'t add role \'%s\'. Config is not set', $name));
|
||||
}
|
||||
if ($this->config->hasSection($name)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
throw new AlreadyExistsException(
|
||||
$this->translate('Can\'t add role \'%s\'. Role already exists'),
|
||||
$name
|
||||
));
|
||||
);
|
||||
}
|
||||
$this->config->setSection($name, $values);
|
||||
return $this;
|
||||
|
|
Loading…
Reference in New Issue