Back

Handling Appwrite exceptions

  • 0
  • Accounts
  • Web
  • Cloud
larkx
9 Oct, 2023, 21:32

Hi, I've got a basic user login and register system built with app write and I'd like to handle appwrite exceptions and show them in the front end (for example, user with that email already exists). What's the best way of doing this?

Currently, I call a function in a separate Appwrite function file for all my authentication stuff so how would I pass the data received in that back to the component / page?

I'm in React btw. Thank you.

TL;DR
The user is asking for the best way to handle Appwrite exceptions in their React application. They want to display these exceptions in the front end. One suggestion is to check the type of the Appwrite exception and display the appropriate message. However, the user mentions they have separate functions for authentication. To pass the data received from these functions back to the component or page, they should use props or state.
Drake
9 Oct, 2023, 21:50

the appwrite exception has a type. You can check that and then display whatever text you want. See https://appwrite.io/docs/advanced/platform/response-codes for more info

larkx
16 Oct, 2023, 17:25

What's the best way of handling these? I've taken a look and they're not categorised at all, and I don't want to handle them all since I'm not using every bit of functionality from Appwrite.

Drake
18 Oct, 2023, 15:54

the user related ones are prefixed with user_. try out to see what's thrown for the endpoint you're using. you can always take a look at the source code as well

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