Duplicate message

This commit is contained in:
fogelito
2024-02-26 14:12:40 +02:00
parent 44ec1502f0
commit 1284df2cb4
5 changed files with 28 additions and 13 deletions
+6 -2
View File
@@ -3495,8 +3495,12 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
);
} catch (AuthorizationException) {
throw new Exception(Exception::USER_UNAUTHORIZED);
} catch (DuplicateException) {
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS);
} catch (DuplicateException $exception) {
$message = 'Document with the requested ID already exists. ';
$message .= !is_null($exception->getCollectionId()) ? ' In Collection ' . $exception->getCollectionId() : '';
$message .= !is_null($exception->getDocumentId()) ? ' Id ' . $exception->getDocumentId() : '';
$message .= 'Try again with a different ID or use ID.unique() to generate a unique ID.';
throw new Exception(Exception::DOCUMENT_ALREADY_EXISTS, $message);
} catch (StructureException $exception) {
throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $exception->getMessage());
}