Back

AppwriteException Localization

  • 1
  • Web
  • Cloud
peppermint
17 Feb, 2024, 02:45

Hi, how to change the exception message according to the user locale? Or if that is not possible how to uniquely identify which exception is which so that it can be handled specifically.

For example if the authentication is failed. I want to display custom error message instead of the default "Invalid credentials. Please check the email and password."

AppwriteException: Invalid credentials. Please check the email and password. at Client.<anonymous> (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=30fb1690:850:17) at Generator.next (<anonymous>) at fulfilled (http://localhost:5173/node_modules/.vite/deps/appwrite.js?v=30fb1690:488:24)

And in some other scenario like changing the user email where the password is required, if incorrect password provided instead of showing " Invalid credentials. Please check the email and password." message I want to show custom error message to explain to the user why the action is failing.

Thanks.

TL;DR
Question: How can I change the exception message based on user locale or uniquely identify exceptions for specific handling in Appwrite? Solution: In order to change the exception message based on user locale, you can modify the default error messages provided by Appwrite by creating a localization file. Unfortunately, there is no built-in feature for identifying or handling exceptions specifically. To overcome this, you can catch specific exceptions using try-catch blocks and handle them accordingly with custom error messages.
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