a better task handling

This commit is contained in:
2017-02-18 02:28:19 +01:00
parent 3c9c045f99
commit 3c35906dd2

View File

@ -380,6 +380,8 @@ public class YaOAuth2Authenticator : WebRedirectAuthenticator
}
var auth = req.GetResponseAsync().ContinueWith(task =>
{
if (task.IsCompleted)
{
var text = task.Result.GetResponseText();
req.Abort();
@ -398,6 +400,15 @@ public class YaOAuth2Authenticator : WebRedirectAuthenticator
{
throw new AuthException("Expected access_token in access token response, but did not receive one.");
}
}
else if (task.IsFaulted)
{
throw new AuthException("Unexpected fault");
}
else
{
throw new AuthException($"Ended: {task.Status}");
}
});