From c15db728795802f585577af7b13d0856e0ab6eac Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Mon, 6 Apr 2026 18:35:17 +0530 Subject: [PATCH] updated error message --- app/controllers/api/migrations.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/migrations.php b/app/controllers/api/migrations.php index 2287ffecfd..67fc21fb48 100644 --- a/app/controllers/api/migrations.php +++ b/app/controllers/api/migrations.php @@ -65,17 +65,22 @@ function getDatabaseResourceType(string $databaseType): string function throwMigrationReportProviderException(\Throwable $e): void { - if ($e->getCode() === 403) { - throw new Exception( - Exception::MIGRATION_PROVIDER_ERROR, - $e->getMessage() !== '' ? $e->getMessage() : 'Missing required scopes.' - ); + $defaultConnectivity = 'Unable to connect to the migration source. Please verify your credentials and ensure the source is reachable from this server. Check for network restrictions such as firewalls, IP allowlists, or outbound connectivity limits.'; + + for ($cur = $e; $cur !== null; $cur = $cur->getPrevious()) { + if (! $cur instanceof \Appwrite\AppwriteException) { + continue; + } + + if ((int) $cur->getCode() === 401 && $cur->getType() === Exception::GENERAL_UNAUTHORIZED_SCOPE) { + throw new Exception( + Exception::GENERAL_UNAUTHORIZED_SCOPE, + $cur->getMessage() !== '' ? $cur->getMessage() : null + ); + } } - throw new Exception( - Exception::MIGRATION_PROVIDER_ERROR, - 'Unable to connect to the migration source. Please verify your credentials and ensure the source is reachable from this server. Check for network restrictions such as firewalls, IP allowlists, or outbound connectivity limits.' - ); + throw new Exception(Exception::MIGRATION_PROVIDER_ERROR, $defaultConnectivity); } Http::post('/v1/migrations/appwrite')