summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-05-02 19:40:10 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-05-02 19:40:10 +0200
commit5ae697ac9dbaf999d51fa7805078249f33c301dc (patch)
treea4f408c9462ff4353820e266efad4864043d08f2 /controller
parente9878cb5b583bc993a9f3a482d0b371bbeea5bd2 (diff)
added proper exception handling for all controllers and businesslayer
Diffstat (limited to 'controller')
-rw-r--r--controller/feedcontroller.php19
-rw-r--r--controller/foldercontroller.php25
-rw-r--r--controller/itemcontroller.php37
3 files changed, 55 insertions, 26 deletions
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index d19008b5a..63a2c3122 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -140,7 +140,6 @@ class FeedController extends Controller {
return $this->renderJSON($params);
} catch(BusinessLayerException $ex) {
-
return $this->renderJSON(array(), $ex->getMessage());
}
}
@@ -155,9 +154,12 @@ class FeedController extends Controller {
$feedId = (int) $this->params('feedId');
$userId = $this->api->getUserId();
- $this->feedBusinessLayer->delete($feedId, $userId);
-
- return $this->renderJSON();
+ try {
+ $this->feedBusinessLayer->delete($feedId, $userId);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -202,9 +204,12 @@ class FeedController extends Controller {
$parentFolderId = (int) $this->params('parentFolderId');
$userId = $this->api->getUserId();
- $this->feedBusinessLayer->move($feedId, $parentFolderId, $userId);
-
- return $this->renderJSON();
+ try {
+ $this->feedBusinessLayer->move($feedId, $parentFolderId, $userId);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php
index f7934ae67..f8d99410d 100644
--- a/controller/foldercontroller.php
+++ b/controller/foldercontroller.php
@@ -71,8 +71,12 @@ class FolderController extends Controller {
* @Ajax
*/
public function open(){
- $this->setOpened(true);
- return $this->renderJSON();
+ try {
+ $this->setOpened(true);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -82,8 +86,12 @@ class FolderController extends Controller {
* @Ajax
*/
public function collapse(){
- $this->setOpened(false);
- return $this->renderJSON();
+ try {
+ $this->setOpened(false);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -121,9 +129,12 @@ class FolderController extends Controller {
$userId = $this->api->getUserId();
$folderId = (int) $this->params('folderId');
- $this->folderBusinessLayer->delete($folderId, $userId);
-
- return $this->renderJSON();
+ try {
+ $this->folderBusinessLayer->delete($folderId, $userId);
+ return $this->renderJSON();
+ } catch (BusinessLayerException $ex){
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php
index a4d9abf3f..d19707f90 100644
--- a/controller/itemcontroller.php
+++ b/controller/itemcontroller.php
@@ -104,9 +104,12 @@ class ItemController extends Controller {
* @Ajax
*/
public function star(){
- $this->setStarred(true);
-
- return $this->renderJSON();
+ try {
+ $this->setStarred(true);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -116,9 +119,12 @@ class ItemController extends Controller {
* @Ajax
*/
public function unstar(){
- $this->setStarred(false);
-
- return $this->renderJSON();
+ try {
+ $this->setStarred(false);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -129,15 +135,19 @@ class ItemController extends Controller {
$this->itemBusinessLayer->read($itemId, $isRead, $userId);
}
+
/**
* @IsAdminExemption
* @IsSubAdminExemption
* @Ajax
*/
public function read(){
- $this->setRead(true);
-
- return $this->renderJSON();
+ try {
+ $this->setRead(true);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}
@@ -147,9 +157,12 @@ class ItemController extends Controller {
* @Ajax
*/
public function unread(){
- $this->setRead(false);
-
- return $this->renderJSON();
+ try {
+ $this->setRead(false);
+ return $this->renderJSON();
+ } catch(BusinessLayerException $ex) {
+ return $this->renderJSON(array(), $ex->getMessage());
+ }
}