如何从云功能返回错误代码“ auth / email-already-exists”给客户端?

时间:2020-06-21 20:01:07

标签: firebase error-handling google-cloud-firestore google-cloud-functions

我有一个云功能,我正在进行一些用户注册,但是如果该电子邮件已经用于其他用户,则无法返回错误代码“ auth / email-already-exists”。

source sheet

我尝试返回Option Explicit Sub look() Dim src As Worksheet: Set src = Workbooks(2).Worksheets(1) Dim dest As Worksheet: Set dest = ThisWorkbook.Worksheets(1) Dim rngSrc As Range Set rngSrc = src.Range(src.Cells(2, 1), src.Cells(2, 1).End(xlDown)) Dim rngDest As Range Set rngDest = dest.Range(dest.Cells(5, 1), dest.Cells(5, 1).End(xlDown)) Dim Path As String: Path = "" Dim file As String: file = "file name" End Sub ,但它一直返回内部。我不明白为什么。

1 个答案:

答案 0 :(得分:2)

您实际上不能将任意字符串值传递给HttpsError()的第一个参数。有效值列表可以在API documentation中找到。这些字符串直接转换为HTTP错误代码。如果您需要特定的错误,则必须找到关闭匹配项(也许是“无效参数”?-您必须决定),然后向其中添加自己的特定错误消息。

请注意,仅在callable function中抛出HttpsError是有意义的。由于您没有说出您要编写的函数类型,也没有显示整个源代码,因此在您不认识的情况下,我会指出这一点。