Quantcast
Channel: User Yura Babiy - Stack Overflow
Viewing all articles
Browse latest Browse all 39

Strange try/catch block behavior

$
0
0

I am working with Github API via Octokit.net. Now I am writing code that responsible for TwoFactorAuth. When I send request for token, if it is 2FA account, than I must get "TwoFactorRequiredException". I am trying to catch it, but insteand of it I get "AggregateException". But when I look in InnerExceptions of Agg..Exc.. then I have only one, and it is "TwoFactorRequiredException".Here is my code:

try{    return client.Authorization.Create(newAuthorization).Result.Token;}catch ( Octokit.TwoFactorRequiredException ){    _navigationService.NavigateAsync($"{nameof(TwoFactorAuthPage)}", animated: false);}//catch ( AggregateException ex )//{//    foreach ( var exception in ex.InnerExceptions )//    {//        Debug.WriteLine(exception.GetType());//    }//}

When it is commented, then I have AggregateExceptions, when it is uncommented, then I have AggExc and inside it I have TwoFactor..Exception.


Viewing all articles
Browse latest Browse all 39

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>