diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-31 02:58:56 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-08-31 02:58:56 +0200 |
commit | 7036a1407c3dce54a6ac5e283ba55720f85ba7de (patch) | |
tree | 7c5fae7ab816a2b0c56b92ca74ebc7cc591d5a3d /external | |
parent | 6f23208ff68d4a8bf2fc20b1fcad6b5e636fb584 (diff) |
Throw proper error codes when creating invalid folders through the API, fix #297
Diffstat (limited to 'external')
-rw-r--r-- | external/feedapi.php | 4 | ||||
-rw-r--r-- | external/folderapi.php | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/external/feedapi.php b/external/feedapi.php index a9fdb4c70..be228d490 100644 --- a/external/feedapi.php +++ b/external/feedapi.php @@ -35,7 +35,7 @@ use \OCA\News\BusinessLayer\FeedBusinessLayer; use \OCA\News\BusinessLayer\FolderBusinessLayer; use \OCA\News\BusinessLayer\ItemBusinessLayer; use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerExistsException; +use \OCA\News\BusinessLayer\BusinessLayerConflictException; class FeedAPI extends Controller { @@ -112,7 +112,7 @@ class FeedAPI extends Controller { return new JSONResponse($result); - } catch(BusinessLayerExistsException $ex) { + } catch(BusinessLayerConflictException $ex) { return new JSONResponse(array('message' => $ex->getMessage()), Http::STATUS_CONFLICT); } catch(BusinessLayerException $ex) { diff --git a/external/folderapi.php b/external/folderapi.php index 31a151c0d..5d2555e10 100644 --- a/external/folderapi.php +++ b/external/folderapi.php @@ -34,7 +34,8 @@ use \OCA\AppFramework\Http\Http; use \OCA\News\BusinessLayer\FolderBusinessLayer; use \OCA\News\BusinessLayer\ItemBusinessLayer; use \OCA\News\BusinessLayer\BusinessLayerException; -use \OCA\News\BusinessLayer\BusinessLayerExistsException; +use \OCA\News\BusinessLayer\BusinessLayerConflictException; +use \OCA\News\BusinessLayer\BusinessLayerValidationException; class FolderAPI extends Controller { @@ -93,7 +94,12 @@ class FolderAPI extends Controller { array_push($result['folders'], $folder->toAPI()); return new JSONResponse($result); - } catch(BusinessLayerExistsException $ex) { + + } catch(BusinessLayerValidationException $ex) { + return new JSONResponse(array('message' => $ex->getMessage()), + Http::STATUS_UNPROCESSABLE_ENTITY); + + } catch(BusinessLayerConflictException $ex) { return new JSONResponse(array('message' => $ex->getMessage()), Http::STATUS_CONFLICT); } @@ -137,7 +143,11 @@ class FolderAPI extends Controller { $this->folderBusinessLayer->rename($folderId, $folderName, $userId); return new JSONResponse(); - } catch(BusinessLayerExistsException $ex) { + } catch(BusinessLayerValidationException $ex) { + return new JSONResponse(array('message' => $ex->getMessage()), + Http::STATUS_UNPROCESSABLE_ENTITY); + + } catch(BusinessLayerConflictException $ex) { return new JSONResponse(array('message' => $ex->getMessage()), Http::STATUS_CONFLICT); |