diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-02 19:40:10 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-05-02 19:40:10 +0200 |
commit | 5ae697ac9dbaf999d51fa7805078249f33c301dc (patch) | |
tree | a4f408c9462ff4353820e266efad4864043d08f2 /businesslayer/itembusinesslayer.php | |
parent | e9878cb5b583bc993a9f3a482d0b371bbeea5bd2 (diff) |
added proper exception handling for all controllers and businesslayer
Diffstat (limited to 'businesslayer/itembusinesslayer.php')
-rw-r--r-- | businesslayer/itembusinesslayer.php | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/businesslayer/itembusinesslayer.php b/businesslayer/itembusinesslayer.php index 72323f413..176669971 100644 --- a/businesslayer/itembusinesslayer.php +++ b/businesslayer/itembusinesslayer.php @@ -93,19 +93,28 @@ class ItemBusinessLayer extends BusinessLayer { } + /** + * @throws BusinessLayerException if the item does not exist + */ public function star($feedId, $guidHash, $isStarred, $userId){ - // FIXME: this can throw two possible exceptions - $item = $this->mapper->findByGuidHash($guidHash, $feedId, $userId); - $item->setLastModified($this->timeFactory->getTime()); - if($isStarred){ - $item->setStarred(); - } else { - $item->setUnstarred(); + try { + $item = $this->mapper->findByGuidHash($guidHash, $feedId, $userId); + $item->setLastModified($this->timeFactory->getTime()); + if($isStarred){ + $item->setStarred(); + } else { + $item->setUnstarred(); + } + $this->mapper->update($item); + } catch(DoesNotExistException $ex) { + throw new BusinessLayerException($ex->getMessage()); } - $this->mapper->update($item); } + /** + * @throws BusinessLayerException if the item does not exist + */ public function read($itemId, $isRead, $userId){ $item = $this->find($itemId, $userId); $item->setLastModified($this->timeFactory->getTime()); @@ -134,6 +143,9 @@ class ItemBusinessLayer extends BusinessLayer { } + /** + * @throws BusinessLayerException if there is no newest item + */ public function getNewestItemId($userId) { try { return $this->mapper->getNewestItemId($userId); |