From 0f9be392f0612739fbf333b4f27823f49ee5a07a Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 23 Oct 2023 16:16:38 +0800 Subject: [PATCH] fix: mongoerror is now mongoservererror --- src/app/models/user.server.model.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/models/user.server.model.ts b/src/app/models/user.server.model.ts index 4bfc391533..88d66dc231 100644 --- a/src/app/models/user.server.model.ts +++ b/src/app/models/user.server.model.ts @@ -114,7 +114,10 @@ const compileUserModel = (db: Mongoose) => { 'save', function (err: Error, _doc: unknown, next: (err?: CallbackError) => void) { if (err) { - if (err.name === 'MongoError' && (err as MongoError)?.code === 11000) { + if ( + ['MongoError', 'MongoServerError'].includes(err.name) && + (err as MongoError)?.code === 11000 + ) { next(new Error('Account already exists with this email')) } else { next(err)