From bf85c7f937715a10600b06e3bf39837c30212f92 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 13 Mar 2026 20:18:40 +1300 Subject: [PATCH] fix: use error code 48 for collection exists exception The createCollection method threw Exception with code 0 when a collection already exists. The database adapter's processException checks for code 48 (MongoDB NamespaceExists) to convert to DuplicateException, which is then handled gracefully. Without the correct code, the exception propagates as a server error. Co-Authored-By: Claude Opus 4.6 --- src/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index 63f51ac..7fd6049 100644 --- a/src/Client.php +++ b/src/Client.php @@ -532,7 +532,7 @@ public function createCollection(string $name, array $options = []): bool $list = $this->listCollectionNames(["name" => $name], $options); if (\count($list->cursor->firstBatch) > 0) { - throw new Exception('Collection Exists'); + throw new Exception('Collection Exists', 48); } $res = $this->query(array_merge([