diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php index b80d0f95..d4212078 100644 --- a/library/Director/Web/Controller/ObjectController.php +++ b/library/Director/Web/Controller/ObjectController.php @@ -6,6 +6,7 @@ use Exception; use Icinga\Exception\IcingaException; use Icinga\Exception\InvalidPropertyException; use Icinga\Exception\NotFoundError; +use Icinga\Module\Director\Exception\DuplicateKeyException; use Icinga\Module\Director\Exception\NestingError; use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Web\Controller\Extension\ObjectRestrictions; @@ -37,6 +38,9 @@ abstract class ObjectController extends ActionController } catch (NotFoundError $e) { $response->setHttpResponseCode(404); $this->sendJson($response, (object) array('error' => $e->getMessage())); + } catch (DuplicateKeyException $e) { + $response->setHttpResponseCode(422); + $this->sendJson($response, (object) array('error' => $e->getMessage())); } catch (Exception $e) { if ($response->getHttpResponseCode() === 200) { $response->setHttpResponseCode(500);