diff --git a/app/config/errors.php b/app/config/errors.php index 36ad4cb896..9e742d3296 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -668,6 +668,11 @@ return [ 'description' => 'The attribute type is invalid.', 'code' => 400, ], + Exception::RELATIONSHIP_VALUE_INVALID => [ + 'name' => Exception::RELATIONSHIP_VALUE_INVALID, + 'description' => 'The relationship value is invalid.', + 'code' => 400, + ], /** Indexes */ Exception::INDEX_NOT_FOUND => [ diff --git a/app/controllers/general.php b/app/controllers/general.php index fef58f541b..4e1b6fa6c4 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -682,6 +682,9 @@ App::error() case 'Utopia\Database\Exception\Authorization': $error = new AppwriteException(AppwriteException::USER_UNAUTHORIZED); break; + case 'Utopia\Database\Exception\Relationship': + $error = new AppwriteException(AppwriteException::RELATIONSHIP_VALUE_INVALID, $error->getMessage(), previous: $error); + break; } $code = $error->getCode(); diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 1c5692cd9d..0ecb435dae 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -195,6 +195,9 @@ class Exception extends \Exception public const ATTRIBUTE_VALUE_INVALID = 'attribute_value_invalid'; public const ATTRIBUTE_TYPE_INVALID = 'attribute_type_invalid'; + /** Relationship */ + public const RELATIONSHIP_VALUE_INVALID = 'relationship_value_invalid'; + /** Indexes */ public const INDEX_NOT_FOUND = 'index_not_found'; public const INDEX_LIMIT_EXCEEDED = 'index_limit_exceeded';