mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
feat: add presence already exists error handling and update exception messages
This commit is contained in:
@@ -731,6 +731,11 @@ return [
|
||||
'description' => 'Presence with the requested ID could not be found.',
|
||||
'code' => 404,
|
||||
],
|
||||
Exception::PRESENCE_ALREADY_EXISTS => [
|
||||
'name' => Exception::PRESENCE_ALREADY_EXISTS,
|
||||
'description' => 'Presence with the requested ID \'%s\' already exists. Try again with a different ID or use ID.unique() to generate a unique ID.',
|
||||
'code' => 409,
|
||||
],
|
||||
|
||||
/** Databases */
|
||||
Exception::DATABASE_NOT_FOUND => [
|
||||
|
||||
@@ -92,9 +92,9 @@ class PresenceState
|
||||
|
||||
return $presence;
|
||||
} catch (DuplicateException $e) {
|
||||
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS, params: [$presenceId], previous: $e);
|
||||
throw new Exception(Exception::PRESENCE_ALREADY_EXISTS, params: [$presenceId], previous: $e);
|
||||
} catch (NotFoundException $e) {
|
||||
throw new Exception(Exception::DOCUMENT_NOT_FOUND, params: [$presenceId], previous: $e);
|
||||
throw new Exception(Exception::PRESENCE_NOT_FOUND, params: [$presenceId], previous: $e);
|
||||
} catch (StructureException $e) {
|
||||
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage(), previous: $e);
|
||||
} catch (ConflictException $e) {
|
||||
|
||||
@@ -204,6 +204,7 @@ class Exception extends \Exception
|
||||
|
||||
/** Presence */
|
||||
public const string PRESENCE_NOT_FOUND = 'presence_not_found';
|
||||
public const string PRESENCE_ALREADY_EXISTS = 'presence_already_exists';
|
||||
|
||||
/** Databases */
|
||||
public const string DATABASE_NOT_FOUND = 'database_not_found';
|
||||
|
||||
@@ -181,7 +181,7 @@ class Update extends PlatformAction
|
||||
try {
|
||||
$presence = $dbForProject->updateDocument('presenceLogs', $presenceId, $updates);
|
||||
} catch (Duplicate $e) {
|
||||
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS, params: [$presenceId], previous: $e);
|
||||
throw new Exception(Exception::PRESENCE_ALREADY_EXISTS, params: [$presenceId], previous: $e);
|
||||
} catch (StructureException $e) {
|
||||
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage(), previous: $e);
|
||||
} catch (ConflictException $e) {
|
||||
|
||||
Reference in New Issue
Block a user