Improve error handling when requesting nonexisting collection
This commit is contained in:
@@ -75,7 +75,11 @@ class Daemon
|
||||
switch ($collectionOp) {
|
||||
case null:
|
||||
if ($request->getMethod() == 'GET') {
|
||||
$result = $this->opCollectionGet($collectionName);
|
||||
try {
|
||||
$result = $this->opCollectionGet($collectionName);
|
||||
} catch (\Exception $e) {
|
||||
return Response::json([ 'error' => "No such collection" ])->withStatus(404);
|
||||
}
|
||||
return Response::json($result);
|
||||
} elseif ($request->getMethod() == 'POST') {
|
||||
$this->opCollectionSet($request, $collectionName);
|
||||
@@ -84,7 +88,11 @@ class Daemon
|
||||
throw new \Exception("Invalid request method");
|
||||
|
||||
case 'all':
|
||||
$result = $this->opCollectionGetAll($collectionName);
|
||||
try {
|
||||
$result = $this->opCollectionGetAll($collectionName);
|
||||
} catch (\Exception $e) {
|
||||
return Response::json([ 'error' => "No such collection" ])->withStatus(404);
|
||||
}
|
||||
return Response::json($result);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user