I am using Cloud Functions methods like:
export const someCallableCloudFunction = functions.https.onCall((data, context) => {
[…]
return new Promise((resolve, reject) => {
[…]
if (someStatement) {
resolve("resolveDataString")
} else {
reject({ status: "error", code: "429", message: "someErrorMessage" })
}
})
})
And calling them with:
firebase.functions().httpsCallable("someCallableCloudFunction")(/*some args*/)
.then(data => { /* data = "resolveDataString" */ })
.catch(error => { /* here's the problem */ })
The issue: This is what the error looks like in the client which calls the method: [Error: INTERNAL]. And this is what the error log looks like in the Firebase Cloud Functions Console (Emulator!):
{
"status": "error",
"code": "429",
"message": "Unhandled error",
"severity": "ERROR"
}
resolve() works perfectly fine but reject() 1) does not print the error object defined in the Cloud Functions method correctly and 2) does not give the error object to the client. Instead the client receives [Error: INTERNAL].
Do I have to use resolve() for both resolve and reject and define statements which can be handled by the client?