GitHost: Improve error handling

In the case of OAuth errors which we get through the message
channel, throwing an exception doesn't help us as the init function
will not be aware about it.

So for now, I've moved the nodejs style error handling in this
particular case.
This commit is contained in:
Vishesh Handa
2019-02-13 22:43:34 +01:00
parent 5452fc0a78
commit c5c4d44431
3 changed files with 16 additions and 6 deletions

View File

@ -30,11 +30,16 @@ class GitHub implements GitHost {
var authCode = uri.queryParameters['code'];
if (authCode == null) {
print("GitHub: Missing auth code. Now what?");
throw GitHostException.OAuthFailed;
callback(GitHostException.OAuthFailed);
}
this._accessCode = await _getAccessCode(authCode);
callback();
if (this._accessCode == null || this._accessCode.isEmpty) {
print("GitHub: AccessCode is invalid: " + this._accessCode);
callback(GitHostException.OAuthFailed);
}
callback(null);
}
_platform.setMethodCallHandler(_handleMessages);