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 <noreply@anthropic.com>
This commit is contained in:
Jake BarnbyandClaude Opus 4.6 committed 2026-03-13 20:18:40 +13:00
1 parent 45bedf36c2
commit bf85c7f937
1 file changed
+1 -1
+1 -1
View File
@@ -532,7 +532,7 @@ class Client
$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([