1
0
Fork 0
mirror of synced 2024-09-30 09:18:14 +13:00

Better error handling

This commit is contained in:
Eldad Fux 2020-03-08 17:38:51 +02:00
parent 0aab05771d
commit 5eedfdd3fe

View file

@ -70,6 +70,10 @@ $utopia->post('/v1/database/collections')
throw new Exception('Failed saving document to DB', 500);
}
if (false === $data) {
throw new Exception('Failed saving collection to DB', 500);
}
$data = $data->getArrayCopy();
$webhook
@ -193,6 +197,7 @@ $utopia->put('/v1/database/collections/:collectionId')
], $rule);
}
try {
$collection = $projectDB->updateDocument(array_merge($collection->getArrayCopy(), [
'name' => $name,
'structure' => true,
@ -201,8 +206,15 @@ $utopia->put('/v1/database/collections/:collectionId')
'read' => $read,
'write' => $write,
],
'rules' => $rules,
'rules' => $parsedRules,
]));
} catch (AuthorizationException $exception) {
throw new Exception('Unauthorized action', 401);
} catch (StructureException $exception) {
throw new Exception('Bad structure. '.$exception->getMessage(), 400);
} catch (\Exception $exception) {
throw new Exception('Failed saving document to DB', 500);
}
if (false === $collection) {
throw new Exception('Failed saving collection to DB', 500);