feat: add presence already exists error handling and update exception messages

This commit is contained in:
ArnabChatterjee20k
2026-05-13 12:30:54 +05:30
parent e799589d11
commit 4e2bd9c307
4 changed files with 9 additions and 3 deletions
+5
View File
@@ -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 => [
+2 -2
View File
@@ -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) {
+1
View File
@@ -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) {