DbObject: Add and use DuplicateKeyException

This commit is contained in:
Markus Frosch 2016-11-24 17:34:17 +01:00
parent d7ddb3e63c
commit ab169e4b78
2 changed files with 9 additions and 1 deletions

View File

@ -10,6 +10,7 @@ namespace Icinga\Module\Director\Data\Db;
use Icinga\Exception\IcingaException as IE;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\Util;
use Exception;
use Zend_Db_Adapter_Abstract;
@ -725,7 +726,7 @@ abstract class DbObject
}
} else {
if ($id && $this->existsInDb()) {
throw new IE(
throw new DuplicateKeyException(
'Trying to recreate %s (%s)',
$table,
$this->getLogId()

View File

@ -0,0 +1,7 @@
<?php
namespace Icinga\Module\Director\Exception;
use Icinga\Exception\IcingaException;
class DuplicateKeyException extends IcingaException {}