This is my exception class. Exception class has been implemented by the abstract exception class of flutter. Am I missing something?
class FetchDataException
Try
void loginUser(String email, String password) async {
try {
var user = await _data
.userLogin(email, password);
_view.onLoginComplete(user);
});
} on FetchDataException catch(e) {
print('error caught: $e');
_view.onLoginError();
}
}
catchError
is sometimes a bit tricky to get right.
With async
/await
you can use try
/catch
like with sync code and it is usually much easier to get right.