diff --git a/app/config/errors.php b/app/config/errors.php index d8a1068f4..77c132f0f 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -401,7 +401,7 @@ return [ /** Project Errors */ Exception::PROJECT_NOT_FOUND => [ 'name' => Exception::PROJECT_NOT_FOUND, - 'description' => 'The requested project could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.', + 'description' => 'Project with the requested ID could not be found. Please check the value of the X-Appwrite-Project header to ensure the correct project ID is being used.', 'code' => 404, ], Exception::PROJECT_UNKNOWN => [ @@ -411,37 +411,32 @@ return [ ], Exception::WEBHOOK_NOT_FOUND => [ 'name' => Exception::WEBHOOK_NOT_FOUND, - 'description' => 'The requested webhook could not be found.', + 'description' => 'Webhook with the requested ID could not be found.', 'code' => 404, ], Exception::KEY_NOT_FOUND => [ 'name' => Exception::KEY_NOT_FOUND, - 'description' => 'The requested key could not be found.', + 'description' => 'Key with the requested ID could not be found.', 'code' => 404, ], Exception::PLATFORM_NOT_FOUND => [ 'name' => Exception::PLATFORM_NOT_FOUND, - 'description' => 'The requested platform could not be found.', + 'description' => 'Platform with the requested ID could not be found.', 'code' => 404, ], Exception::DOMAIN_NOT_FOUND => [ 'name' => Exception::DOMAIN_NOT_FOUND, - 'description' => 'The requested domain could not be found.', + 'description' => 'Domain with the requested ID could not be found.', 'code' => 404, ], Exception::DOMAIN_ALREADY_EXISTS => [ 'name' => Exception::DOMAIN_ALREADY_EXISTS, - 'description' => 'The requested domain already exists.', + 'description' => 'A Domain with the requested ID already exists.', 'code' => 409, ], - Exception::DOMAIN_UNREACHABLE => [ - 'name' => Exception::DOMAIN_UNREACHABLE, - 'description' => 'The requested domain is not reachable.', - 'code' => 503, - ], Exception::DOMAIN_VERIFICATION_FAILED => [ 'name' => Exception::DOMAIN_VERIFICATION_FAILED, - 'description' => 'The requested domain verification failed.', - 'code' => 503, + 'description' => 'Domain verification for the requested domain has failed.', + 'code' => 401, ] ]; \ No newline at end of file diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index df6ab569f..cb2eb0e73 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -1236,7 +1236,7 @@ App::post('/v1/projects/:projectId/domains') $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); if (!$target->isKnown() || $target->isTest()) { - throw new Exception('Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.', 500, Exception::DOMAIN_UNREACHABLE); + throw new Exception('Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.', 500, Exception::GENERAL_SERVER_ERROR); } $domain = new Domain($domain); @@ -1367,7 +1367,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification') $target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', '')); if (!$target->isKnown() || $target->isTest()) { - throw new Exception('Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.', 500, Exception::DOMAIN_UNREACHABLE); + throw new Exception('Unreachable CNAME target (' . $target->get() . '), please use a domain with a public suffix.', 500, Exception::GENERAL_SERVER_ERROR); } if ($domain->getAttribute('verification') === true) { @@ -1377,6 +1377,7 @@ App::patch('/v1/projects/:projectId/domains/:domainId/verification') $validator = new CNAME($target->get()); // Verify Domain with DNS records if (!$validator->isValid($domain->getAttribute('domain', ''))) { + // TODO: Isn't 401 Unauthorized ? Should we return a 400 Bad Request ? throw new Exception('Failed to verify domain', 401, Exception::DOMAIN_VERIFICATION_FAILED); } diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 113e17e23..3dfb02ff6 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -151,7 +151,6 @@ class Exception extends \Exception /** Domain */ const DOMAIN_NOT_FOUND = 'domain_not_found'; const DOMAIN_ALREADY_EXISTS = 'domain_already_exists'; - const DOMAIN_UNREACHABLE = 'domain_unreachable'; const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';