diff options
author | René Gieling <github@dartcafe.de> | 2020-08-23 08:59:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 08:59:02 +0300 |
commit | bdece5963ba5a88a841ed0dd04050bb1958c2a0f (patch) | |
tree | c16490cd29c049b0a0efe9366dddc37af6681f50 /lib/Controller | |
parent | f29310618551b688c2bab412cb127b37c64ea3f2 (diff) | |
parent | 6b73deac12a2dabc4d94b92ce91eebd04620e3bb (diff) |
Merge branch 'dev-1.5' into checkCalendar
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/OptionController.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Controller/OptionController.php b/lib/Controller/OptionController.php index 3416a399..d8801d69 100644 --- a/lib/Controller/OptionController.php +++ b/lib/Controller/OptionController.php @@ -26,6 +26,7 @@ namespace OCA\Polls\Controller; use DateTime; use DateInterval; use Exception; +use OCA\Polls\Exceptions\DuplicateEntryException; use OCP\IRequest; @@ -79,7 +80,11 @@ class OptionController extends Controller { * @return DataResponse */ public function add($pollId, $timestamp = 0, $pollOptionText = '') { - return new DataResponse(['option' => $this->optionService->add($pollId, $timestamp, $pollOptionText)], Http::STATUS_OK); + try { + return new DataResponse(['option' => $this->optionService->add($pollId, $timestamp, $pollOptionText)], Http::STATUS_OK); + } catch (DuplicateEntryException $e) { + return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); + } } /** |