微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Firebase Cloud功能:在try catch块内引发Https错误

如何解决Firebase Cloud功能:在try catch块内引发Https错误

我在可调用的Cloud函数中使用TypeScript。它们的结构如下所示:

exports.sayHello = functions.https.onCall(async (data,context) => {
    try {
        const email: string = data.email;
        const isstudent: boolean = data.isstudent

        if (isstudent) {
            const mathGrade: string = data.mathgrade;

            try {
                // Access Firestore
            } catch (error) {
                // Throw Https error
            }

        } else {
            const mainSubject: string = data.mainsubject;      
            try {
                // Access Firestore
            } catch (error) {
                // Throw Https error
            } 
        }
    } catch (error) {
        // Handle type error (the typecasting Failed because of the json data)
    }
});

我现在的问题是,我抛出的Https错误是否会被外部try catch块捕获,因为我想要的是将其发送给客户端

解决方法

是的,它会被外部捕获物捕获。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。