summaryrefslogtreecommitdiffstats
path: root/lib/Service/Service.php
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-01-02 17:57:17 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-02-13 13:22:57 +0100
commitb4fa772bc5f23f84fc292f5d6bf884543d2bfe51 (patch)
tree8576ad3ea145f3644804e2fd93de462cfc2c2578 /lib/Service/Service.php
parentceba81060303e49b2617397397f2804516052ec9 (diff)
Remove V1 item API
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Service/Service.php')
-rw-r--r--lib/Service/Service.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Service/Service.php b/lib/Service/Service.php
index 1d7fdffb6..951d460f6 100644
--- a/lib/Service/Service.php
+++ b/lib/Service/Service.php
@@ -14,6 +14,7 @@
namespace OCA\News\Service;
use OCA\News\Db\NewsMapperV2;
+use OCA\News\Service\Exceptions\ServiceConflictException;
use OCA\News\Service\Exceptions\ServiceNotFoundException;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\Entity;
@@ -65,14 +66,13 @@ abstract class Service
*/
abstract public function findAll(): array;
-
/**
* Delete an entity
*
* @param int $id the id of the entity
* @param string $userId the name of the user for security reasons
*
- * @throws ServiceNotFoundException if the entity does not exist, or there
+ * @throws ServiceNotFoundException|ServiceConflictException if the entity does not exist, or there
* are more than one of it
*/
public function delete(string $userId, int $id): Entity
@@ -102,7 +102,7 @@ abstract class Service
* @param string $userId the name of the user for security reasons
* @param Entity $entity the entity
*
- * @throws ServiceNotFoundException if the entity does not exist, or there
+ * @throws ServiceNotFoundException|ServiceConflictException if the entity does not exist, or there
* are more than one of it
*/
public function update(string $userId, Entity $entity): Entity
@@ -119,7 +119,7 @@ abstract class Service
* @param string $userId the name of the user for security reasons
*
* @return Entity the entity
- * @throws ServiceNotFoundException if the entity does not exist, or there
+ * @throws ServiceNotFoundException|ServiceConflictException if the entity does not exist, or there
* are more than one of it
*/
public function find(string $userId, int $id): Entity
@@ -127,9 +127,9 @@ abstract class Service
try {
return $this->mapper->findFromUser($userId, $id);
} catch (DoesNotExistException $ex) {
- throw new ServiceNotFoundException($ex->getMessage());
+ throw ServiceNotFoundException::from($ex);
} catch (MultipleObjectsReturnedException $ex) {
- throw new ServiceNotFoundException($ex->getMessage());
+ throw ServiceConflictException::from($ex);
}
}