I use TypeScript in my callable Cloud functions. Their structure looks something like this:
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)
}
});
My question now is if the Https errors I throw would be caught by the outer try catch block, because what I want is send them to client
Yes, it would be caught by the outer catch.