[icinga-checkins] icinga.org: icingaweb2-module-director/master: DbObject: Add and use DuplicateKeyException

git at icinga.org git at icinga.org
Wed Nov 30 09:24:52 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: ab169e4b7869f0553e55dcb032fecc521f6a9209
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=ab169e4b7869f0553e55dcb032fecc521f6a9209

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Thu Nov 24 17:34:17 2016 +0100

DbObject: Add and use DuplicateKeyException

---

 library/Director/Data/Db/DbObject.php                |    3 ++-
 library/Director/Exception/DuplicateKeyException.php |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/library/Director/Data/Db/DbObject.php b/library/Director/Data/Db/DbObject.php
index 77e2f6b..72d014a 100644
--- a/library/Director/Data/Db/DbObject.php
+++ b/library/Director/Data/Db/DbObject.php
@@ -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()
diff --git a/library/Director/Exception/DuplicateKeyException.php b/library/Director/Exception/DuplicateKeyException.php
new file mode 100644
index 0000000..ed0d012
--- /dev/null
+++ b/library/Director/Exception/DuplicateKeyException.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace Icinga\Module\Director\Exception;
+
+use Icinga\Exception\IcingaException;
+
+class DuplicateKeyException extends IcingaException {}



More information about the icinga-checkins mailing list