1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

feat: update descriptions of projects errors

This commit is contained in:
Christy Jacob 2022-02-08 03:23:07 +04:00
parent d504ef2607
commit 12794f4214
3 changed files with 11 additions and 16 deletions

View file

@ -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,
]
];

View file

@ -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);
}

View file

@ -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';