core: better duplicate key error msg

This commit is contained in:
undefined committed 2022-07-05 10:32:23 +08:00
1 parent 7e3314774a
commit fc85ca36dc
1 file changed
+5 -2
+5 -2
View File
@@ -303,8 +303,11 @@ class UserModel {
avatar: `gravatar:${mail}`,
});
} catch (e) {
logger.warn('%o', e);
throw new UserAlreadyExistError([uid, uname, mail]);
if (e?.code === 11000) {
// Duplicate Key Error
throw new UserAlreadyExistError(Object.values(e?.keyValue || {}));
}
throw e;
}
return uid;
}