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
- android platform invaild origina
It happened today suddenly. Our app says invalid origin. And appwrite cloud says every time we tried to add the app to it: "param platformId" is not optional.
- Team invite - 500 error - no email
When executing ```dart await _repository.teams.createMembership( teamId: event.listId, roles: ['member'], email: event.email, url: 'xxxx', ); ``` I se...
- Help with nameservers
I just added our domain, and as per instruction in the page following, it says, "Add the following nameservers on your DNS provider. ..." I want to keep my cu...