我在我的可调用Firebase函数中抛出了一个错误:
throw new functions.https.HttpsError(
'invalid-argument',
`Invalid token ${token} for file ${fileName}.`
);在日志中,我只看到以下内容:
12:29:22.500 PM SQR-cancelAllotment Function execution took 1779 ms, finished with status code: 400
12:29:20.722 PM SQR-cancelAllotment Function execution started因此,代码400没有显示任何错误消息。为什么?
我不想在单独的console.error中复制错误消息。
发布于 2019-10-14 23:14:03
抛出HttpsError是向客户端发出的信号,表明函数未按预期工作。这并不意味着函数以崩溃而终止(这将被记录下来)。当您抛出一个HttpsError时,如果您想在日志中看到一条消息,您还应该调用console.error() (或您想要的任何日志级别),以便显示该消息。
发布于 2019-10-14 21:53:34
对于在云函数中抛出错误,您可以使用Stackdriver Error Reporting client libraries
你可以在这里找到设置错误报告的documentation (你也有一些例子)
https://stackoverflow.com/questions/58370628
复制相似问题