【问题标题】:Firebase Cloud Functions: Throw Https error inside try catch blockFirebase Cloud Functions:在 try catch 块中引发 Https 错误
【发布时间】:2020-09-07 20:33:49
【问题描述】:

我在可调用的云函数中使用 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 块捕获,因为我想要将它们发送给客户端

【问题讨论】:

    标签: typescript firebase google-cloud-functions try-catch throw


    【解决方案1】:

    是的,它会被外接物捕捉到。

    【讨论】:

      猜你喜欢
      • 2017-10-05
      • 2018-06-11
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 1970-01-01
      相关资源
      最近更新 更多