From f658beaf61962686738946211101321e2dcf860c Mon Sep 17 00:00:00 2001 From: Daniel Schaal Date: Fri, 18 Nov 2016 16:03:31 +0100 Subject: Throw ServiceNotFoundException when marking non-existent item as read (#61) * Throw ServiceNotFoundException when marking non-existent item as read Fixes #58 * Add test case for marking non-existent item as read --- lib/Service/ItemService.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Service/ItemService.php b/lib/Service/ItemService.php index fdf97c27b..f657b3eff 100644 --- a/lib/Service/ItemService.php +++ b/lib/Service/ItemService.php @@ -147,8 +147,12 @@ class ItemService extends Service { * @throws ServiceNotFoundException if the item does not exist */ public function read($itemId, $isRead, $userId){ - $lastModified = $this->timeFactory->getMicroTime(); - $this->itemMapper->readItem($itemId, $isRead, $lastModified, $userId); + try { + $lastModified = $this->timeFactory->getMicroTime(); + $this->itemMapper->readItem($itemId, $isRead, $lastModified, $userId); + } catch(DoesNotExistException $ex) { + throw new ServiceNotFoundException($ex->getMessage()); + } } -- cgit v1.2.3