Combine Duplicate/Limit catches in createField

Same shape as the row-flush combine: multi-type catch with a small
ternary for the per-type message. Two pairs collapsed: the single
attribute path and the relationship two-way path (which differ only
in 'Attribute limit exceeded' vs 'Column limit exceeded').
This commit is contained in:
Prem Palanisamy committed 2026-05-04 11:06:03 +01:00
1 parent 0710fde3a9
commit 3fdcd27925
1 file changed
+8 -28
+8 -28
View File
@@ -691,23 +691,14 @@ class Appwrite extends Destination
$this->dbForProject->checkAttribute($table, $column);
$column = $this->dbForProject->createDocument('attributes', $column);
} catch (DuplicateException $e) {
$resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists');
} catch (DuplicateException | LimitException $e) {
$message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Attribute limit exceeded';
$resource->setStatus(Resource::STATUS_ERROR, $message);
$this->addError(new Exception(
resourceName: $resource->getName(),
resourceGroup: $resource->getGroup(),
resourceId: $resource->getId(),
message: 'Attribute already exists',
previous: $e,
));
return false;
} catch (LimitException $e) {
$resource->setStatus(Resource::STATUS_ERROR, 'Attribute limit exceeded');
$this->addError(new Exception(
resourceName: $resource->getName(),
resourceGroup: $resource->getGroup(),
resourceId: $resource->getId(),
message: 'Attribute limit exceeded',
message: $message,
previous: $e,
));
return false;
@@ -753,27 +744,16 @@ class Appwrite extends Destination
]);
$this->dbForProject->createDocument('attributes', $twoWayAttribute);
} catch (DuplicateException $e) {
} catch (DuplicateException | LimitException $e) {
$this->dbForProject->deleteDocument('attributes', $column->getId());
$resource->setStatus(Resource::STATUS_ERROR, 'Attribute already exists');
$message = $e instanceof DuplicateException ? 'Attribute already exists' : 'Column limit exceeded';
$resource->setStatus(Resource::STATUS_ERROR, $message);
$this->addError(new Exception(
resourceName: $resource->getName(),
resourceGroup: $resource->getGroup(),
resourceId: $resource->getId(),
message: 'Attribute already exists',
previous: $e,
));
return false;
} catch (LimitException $e) {
$this->dbForProject->deleteDocument('attributes', $column->getId());
$resource->setStatus(Resource::STATUS_ERROR, 'Column limit exceeded');
$this->addError(new Exception(
resourceName: $resource->getName(),
resourceGroup: $resource->getGroup(),
resourceId: $resource->getId(),
message: 'Column limit exceeded',
message: $message,
previous: $e,
));
return false;