Back

[SOLVED] Manage unhandled exception

  • 0
  • Flutter
D5
26 Mar, 2023, 15:53

Tried making this to handle existing sessions: Https://github.com/appwrite/appwrite/discussions/3938#discussioncomment-3746725

When using account.get() to see if there is a session or not, instead of catching the exception, it just shows unhandled exception general authorization scope in the console (not printing the error and not making what's inside catch(e)).

Here is the code used:

TypeScript
manageLogin() {

try{
   account.get();
}
catch(e){
   print(e);
}

}
TL;DR
Title: [SOLVED] Issue with handling unhandled exception in code Solution: The code snippet provided is not properly handling the exception. To fix this, the code should be updated as follows: ```dart manageLogin() async { try { await account.get(); } catch (e) { print(e); } } ``` By adding the `async` keyword before the function declaration and `await` before the `account.get()` method, the code will properly handle the exceptions and display the error message in the console.
Maniac_Fighter
26 Mar, 2023, 16:01

this function needs async await

D5
26 Mar, 2023, 16:01

I will try that

D5
26 Mar, 2023, 16:06

Yes, worked 😅

D5
26 Mar, 2023, 16:07

[SOLVED] Manage unhandled exception

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