Back

CloudFunctions, Error Throw

  • 0
  • Web
Camo
22 Feb, 2024, 15:10

What is the correct way to throw error, and get a failed state in the cloud functions? I get 200, when there are actuall errors. And i want to know exactly when something fails. Node.

TL;DR
Developers want to know how to properly throw errors in Cloud Functions to ensure a failed state is returned. They are currently receiving a 200 status code even when there are errors. The correct way to throw an error in Node.js is by using `throw new Error("Error message");`. By not catching the error, the function will indeed fail.
Kenny
22 Feb, 2024, 15:25

I thought it was just throwing, so if you did throw new Error("Error message"); without catching it it would cause the function to fail?

Camo
22 Feb, 2024, 15:49

ive could have left the catch in, let me get back home and check it out

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more