
Hello again, sorry for bother you guys.
I'm getting this exception when trying to login. I put bad credentials on purpose.
I just want to know how to catch this exceptions, I have added already onError, and make it returns null. But it throws another exception.
This is my code:
Future? login({required String email, required String password}) {
try {
return account
.createEmailSession(email: email, password: password)
.then((value) => value)
.onError((error) => null); // <-- null is marked as error, Want to know with what can I replace that
} catch (e) {
print(e);
return null;
}
}
Thanks for your help

As the error says, you must return a value of the future's type (in this case, session) and can't return null.
Btw, i highly suggest you avoid trying to mix and match then/onError with try/catch. When possible, only use async/await/try/catch as it makes code much easier to read

You point me in the right direction, using async await turns into more readable code and easy debug.
Thank you so much @Steven!
You are awesome

[SOLVED] How to catch on promise errors?
Recommended threads
- Still an issue? On user deletion, target...
This has been mentioned here: https://discord.com/channels/564160730845151244/1295830646039515146 and as a Github issue here: https://github.com/appwrite/appwri...
- Appwrite database is rounding int values
Hi, i just noticed that appwrite is rounding the value 608542412536545279 to 608542412536545300 in my int array. It seems to somewhat relate to this github iss...
- OAuth fails with Invalid Response or inv...
Im currently trying to use the Discord Oauth but i cant find a way to make it work. I followed the docs and set up the discord oauth application and enabled it...
