Skip to content

Commit 10cf13d

Browse files
abnegateclaude
andcommitted
fix: handle client-level Collection Exists exception in Mongo processException
The Mongo client throws Exception('Collection Exists') with code 0 rather than using MongoDB's native error code 48. This was only caught by the pre-check, leaving the in-transaction path unhandled. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 602f8de commit 10cf13d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Database/Adapter/Mongo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3520,8 +3520,8 @@ protected function processException(\Throwable $e): \Throwable
35203520
return new DuplicateException('Document already exists', $e->getCode(), $e);
35213521
}
35223522

3523-
// Collection already exists
3524-
if ($e->getCode() === 48) {
3523+
// Collection already exists (code 48 from MongoDB, code 0 from client pre-check)
3524+
if ($e->getCode() === 48 || ($e->getCode() === 0 && stripos($e->getMessage(), 'Collection Exists') !== false)) {
35253525
return new DuplicateException('Collection already exists', $e->getCode(), $e);
35263526
}
35273527

0 commit comments

Comments
 (0)