From 0710fde3a99f7236f8bbcf2bf5fc860da0378535 Mon Sep 17 00:00:00 2001 From: Prem Palanisamy Date: Mon, 4 May 2026 11:03:40 +0100 Subject: [PATCH] Combine Duplicate/Structure catches at row-flush; trim verbose comments DB adapters already normalise DuplicateException's message to 'Document already exists', so a multi-type catch with $e->getMessage() collapses both branches into one without changing user-visible behaviour. Trimmed the safety-net comment to a single line. --- src/Migration/Destinations/Appwrite.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Migration/Destinations/Appwrite.php b/src/Migration/Destinations/Appwrite.php index fab054399c..67a20a15c7 100644 --- a/src/Migration/Destinations/Appwrite.php +++ b/src/Migration/Destinations/Appwrite.php @@ -333,10 +333,8 @@ class Appwrite extends Destination default => throw new \Exception('Invalid resource group', Exception::CODE_VALIDATION), }; } catch (\Throwable $e) { - // Safety net: expected user-data failures are recorded inline by the - // create*() methods via setStatus + addError + return false. Anything - // reaching here is a library bug or infra failure — record it for the - // user, then rethrow so the worker boundary can route it to Sentry. + // Safety net for unexpected failures — record on the migration and + // rethrow so the worker boundary can route bugs to Sentry. $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( @@ -1132,17 +1130,7 @@ class Appwrite extends Destination fn () => $dbForDatabases->createDocuments($collectionId, $this->rowBuffer) ), }; - } catch (DuplicateException $e) { - $resource->setStatus(Resource::STATUS_ERROR, 'Document already exists'); - $this->addError(new Exception( - resourceName: $resource->getName(), - resourceGroup: $resource->getGroup(), - resourceId: $resource->getId(), - message: 'Document already exists', - previous: $e, - )); - return false; - } catch (StructureException $e) { + } catch (DuplicateException | StructureException $e) { $resource->setStatus(Resource::STATUS_ERROR, $e->getMessage()); $this->addError(new Exception( resourceName: $resource->getName(),