【发布时间】: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