mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
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:
@ -30,11 +30,16 @@ class GitHub implements GitHost {
|
|||||||
var authCode = uri.queryParameters['code'];
|
var authCode = uri.queryParameters['code'];
|
||||||
if (authCode == null) {
|
if (authCode == null) {
|
||||||
print("GitHub: Missing auth code. Now what?");
|
print("GitHub: Missing auth code. Now what?");
|
||||||
throw GitHostException.OAuthFailed;
|
callback(GitHostException.OAuthFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._accessCode = await _getAccessCode(authCode);
|
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);
|
_platform.setMethodCallHandler(_handleMessages);
|
||||||
|
@ -36,15 +36,17 @@ class GitLab implements GitHost {
|
|||||||
print("GitLab: OAuth State incorrect");
|
print("GitLab: OAuth State incorrect");
|
||||||
print("Required State: " + _stateOAuth);
|
print("Required State: " + _stateOAuth);
|
||||||
print("Actual State: " + state);
|
print("Actual State: " + state);
|
||||||
throw GitHostException.OAuthFailed;
|
callback(GitHostException.OAuthFailed);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_accessCode = map['access_token'];
|
_accessCode = map['access_token'];
|
||||||
if (_accessCode == null) {
|
if (_accessCode == null) {
|
||||||
throw GitHostException.OAuthFailed;
|
callback(GitHostException.OAuthFailed);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
_platform.setMethodCallHandler(_handleMessages);
|
_platform.setMethodCallHandler(_handleMessages);
|
||||||
|
@ -29,7 +29,10 @@ class GitHostSetupAutoConfigureState extends State<GitHostSetupAutoConfigure> {
|
|||||||
print("Starting autoconfigure");
|
print("Starting autoconfigure");
|
||||||
gitHost = createGitHost(widget.gitHostType);
|
gitHost = createGitHost(widget.gitHostType);
|
||||||
try {
|
try {
|
||||||
gitHost.init(() async {
|
gitHost.init((Exception error) async {
|
||||||
|
if (error != null) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
print("GitHost Initalized: " + widget.gitHostType.toString());
|
print("GitHost Initalized: " + widget.gitHostType.toString());
|
||||||
|
|
||||||
GitRepo repo;
|
GitRepo repo;
|
||||||
|
Reference in New Issue
Block a user