Catch exceptions in one block

This commit is contained in:
kodumbeats
2021-09-09 13:15:30 -04:00
parent 624d099bf9
commit f5d69b4b0a
+5 -8
View File
@@ -88,16 +88,13 @@ $attributesCallback = function ($collectionId, $attribute, $response, $dbForInte
try {
$dbForInternal->checkAttribute($collection, $attribute);
} catch (LimitException $exception) {
throw new Exception('Attribute limit exceeded', 400);
}
try {
$attribute = $dbForInternal->createDocument('attributes', $attribute);
} catch (DuplicateException $th) {
}
catch (DuplicateException $exception) {
throw new Exception('Attribute already exists', 409);
} catch (LimitException $e) {
throw new Exception($e->getMessage(), 400);
}
catch (LimitException $exception) {
throw new Exception('Attribute limit exceeded', 400);
}
$dbForInternal->purgeDocument('collections', $collectionId);