Back

Functions Return Status Code

  • 0
  • Functions
Tanner Meade
14 Feb, 2023, 14:58

I'm trying to return a custom status code (error 500) when a dart cloud function fails. Using the below doesn't seem to be working. Am I missing something?

TypeScript
res.json(
  {"msg": "function failed"},
  status: 500,
);
TL;DR
The user wants to know when a feature will be released and is having trouble getting the expected error code from the QStash API. The next version of Functions will have an update that allows for setting a custom status code. The user is looking for a way to return a failure from a cloud function without throwing an exception. The code they provided to return a custom status code (500) is not working and they are wondering if they are missing something.
Tanner Meade
14 Feb, 2023, 15:17

I haven't figured out how to return a failure from a cloud function without throwing an exception, which can cause the cloud function to run until it times out. Ideally, I'd like to figure out how to get the execution to have "failed" programmatically and the response code returned to the client have an HTTP status code of 500.

Eldad
14 Feb, 2023, 15:32

Next version of Functions will allow you to set a custom status code it will be executed a bit differently, but have full backward support. cc @Meldiron

Tanner Meade
14 Feb, 2023, 15:33

Thanks Eldad! Really looking forward to the functions update! ๐Ÿ”ฅ๐Ÿš€

Eldad
14 Feb, 2023, 15:35

The next release of Functions is going to be an industry game changer. This is only a tiny piece of what to expect. ๐Ÿคž

Meldiron
14 Feb, 2023, 15:35

I promised Tanner to share branch as soon as it is working, for QA ๐Ÿ˜Ž

Eldad
14 Feb, 2023, 15:35

Very cool!

Lucas Reis
26 Jun, 2023, 21:32

hello folks, hope you are doing well.

Any idea of when this feature will be released?

I am trying to use QStash to handle retryings in case of any error on a appwrite function, but the api must return a error code. In my case it only returns 201 no matter what happens on the server side.

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