Firebase Cloud Functions:在 try catch 块内抛出 Https 错误

Firebase Cloud Functions: Throw Https error inside try catch block

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

是的,它会被外层捕获。