【发布时间】:2020-06-21 20:01:07
【问题描述】:
我有一个云功能,我正在执行一些用户注册,但如果电子邮件已被其他用户使用,我无法让它返回错误代码“auth/email-already-exists”。
catch (error) {
if (error.type === 'UnauthenticatedError') {
throw new functions.https.HttpsError('unauthenticated', error.message);
} else if (error.type === 'NotAnAdminError' || error.type === 'InvalidRoleError') {
throw new functions.https.HttpsError('failed-precondition', error.message);
} else if (error.code === 'auth/email-already-exists') {
//return the error code here
} else {
throw new functions.https.HttpsError('internal', error.type);
}
}
我已尝试返回 throw new functions.https.HttpsError('email exists', error);,但它一直返回 INTERNAL。我不明白为什么。
【问题讨论】:
标签: firebase error-handling google-cloud-firestore google-cloud-functions