diff options
author | dartcafe <github@dartcafe.de> | 2020-06-22 19:55:42 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-06-22 19:55:42 +0300 |
commit | 863d50ecfa2963664cb16892d31af65ad3289b5e (patch) | |
tree | a7e602e4bba24c103d4fd071b29e6e4c1cb314d0 /lib/Controller/SubscriptionController.php | |
parent | 0d632d59b202f55da389db28b870b8c64416c00f (diff) |
code maintenance
Diffstat (limited to 'lib/Controller/SubscriptionController.php')
-rw-r--r-- | lib/Controller/SubscriptionController.php | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php index f3cc655a..194b97e6 100644 --- a/lib/Controller/SubscriptionController.php +++ b/lib/Controller/SubscriptionController.php @@ -25,6 +25,7 @@ namespace OCA\Polls\Controller; use Exception; use OCP\AppFramework\Db\DoesNotExistException; +use OCA\Polls\Exceptions\NotAuthorizedException; use OCP\IRequest; use OCP\ILogger; @@ -73,9 +74,9 @@ class SubscriptionController extends Controller { try { return new DataResponse($this->subscriptionService->get($pollId), Http::STATUS_OK); } catch (NotAuthorizedException $e) { - return new DataResponse('Unauthorized', Http::STATUS_FORBIDDEN); + return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); } catch (DoesNotExistException $e) { - return new DataResponse('Not subscribed', Http::STATUS_NOT_FOUND); + return new DataResponse(['error' => 'Not subscribed'], Http::STATUS_NOT_FOUND); } } @@ -88,7 +89,7 @@ class SubscriptionController extends Controller { try { return new DataResponse($this->subscriptionService->set($pollId, $subscribed), Http::STATUS_OK); } catch (NotAuthorizedException $e) { - return new DataResponse('Unauthorized', Http::STATUS_FORBIDDEN); + return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); } } } |