Back

Avoid console error messages

  • 0
  • Web
leonardorick
12 Oct, 2023, 16:01

Api errors keeps appearing even when I wrap the methods call with a try/catch

The API error on the image appears when I run the following code

TypeScript
  try {
    const session = await auth.getSession('current');
    sessionId = session.$id;
  } catch (error) {
    initializerClientError = error;
  }

Is there a way to avoid this messages at all? or to check if a session exists in a way that do not throw an error?

TL;DR
The user is asking for ways to avoid console error messages for API errors. The user has tried using try/catch but it didn't work. One suggestion is to use a condition/switch statement to show custom error messages based on the appwrite error message. Another suggestion is to customize the error messages client-sided after getting the error. The user also asks if there is a way to check if a session exists without throwing an error.
leonardorick
12 Oct, 2023, 16:01

Avoid console error messages

D5
13 Oct, 2023, 17:51

You mean the error being shown to the user?

D5
13 Oct, 2023, 17:51

If so, you could customise them client sided after getting the error

D5
13 Oct, 2023, 17:54

You can do a condition/switch and depending on the appwrite error message you show your own error message

leonardorick
13 Oct, 2023, 19:08

@D5 I mean the error that appears on the console. I can't avoid it even with the try/catch

D5
13 Oct, 2023, 19:13

Supposedly that should not be seen by anyone

Drake
13 Oct, 2023, 19:37

yup nothing you can do about that. any non 400 and above http status response will show up here

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