OAuthException not caught with C # FacebookSDK

I am trying to get my code to catch certain errors. I save the token for the user after he or she grants permission to my application (this is a WP7 application). When I try to post to the wall using a stored token, it works. When I delete permissions on facebook, it throws an OAuthException. I can’t catch it. My application just crashes. This is the code I used:

private object PostToFacebook() { _fbApp = new FacebookClient(_appsettings.faceBookToken); FacebookAsyncCallback callback = new FacebookAsyncCallback(this.postResult); var parameters = new Dictionary<string, object>(); parameters.Add("message", "message on wall"); try { _fbApp.PostAsync("me/feed", parameters, callback); } catch (Exception ex) { } return null; } private void postResult(FacebookAsyncResult asyncResult) { if (asyncResult.Error == null) { status = "succes"; } else { status = "error" + asyncResult.Error.Message; } } 

The try catcher will catch nothing and the general exception handler in my app.xaml.cs too.

Any ideas how to catch this error so that I can ask the user to authenticate again?

0
source share
1 answer

Put your try..catch in the callback.

You can also catch exceptions globally by handling the UnhandledException event in the App object.

0
source

Source: https://habr.com/ru/post/1343659/


All Articles