Back

Handling failed executions of function

  • 0
  • Functions
  • Web
  • Cloud
larkx
18 Mar, 2024, 15:05

Hello, how do I handle the failed execution of serverless functions? I've tried using try & catch blocks but it doesn't seem to work.

TL;DR
Developers are trying to handle failed serverless function executions using try/catch blocks but it's not working as expected. The issue lies in not checking the response for errors when calling the function in the front-end. Ensure to evaluate the response and catch any errors properly.
Steven
18 Mar, 2024, 15:09

What failure are you referring to?

larkx
18 Mar, 2024, 15:23

Just a fail to execute

larkx
18 Mar, 2024, 15:23

For one reason or another

Steven
18 Mar, 2024, 15:23

And why is it failing?

Where are you doing a try/catch?

larkx
18 Mar, 2024, 15:25

In the front-end where I call the function

TypeScript
try {
  await functions.createExecution('<>', JSON.stringify(payload), false, "/", "PATCH")
} catch(error) {
  if (error instanceof AppwriteException) {
    console.error(error.message);
  } else {
    console.error(error);
  }
}
Steven
18 Mar, 2024, 15:26

It doesn't throw an error. You'll need to look at the response

larkx
18 Mar, 2024, 15:27

Oh okay, thanks

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