Skip to content

Better facebook error handling #368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookRequestError;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
Expand Down Expand Up @@ -125,12 +126,24 @@ public void onSuccess(final LoginResult loginResult) {
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
try {
String email = object.getString("email");
mCallbackObject.onSuccess(createIDPResponse(loginResult, email));
} catch (JSONException e) {
e.printStackTrace();
FacebookRequestError requestError = response.getError();
if(requestError != null) {
Log.e(TAG,
"Received Facebook error: " + requestError.getErrorMessage());
mCallbackObject.onFailure(new Bundle());
return;
}
if (object == null) {
Log.w(TAG, "Received null response from Facebook GraphRequest");
mCallbackObject.onFailure(new Bundle());
} else {
try {
String email = object.getString("email");
mCallbackObject.onSuccess(createIDPResponse(loginResult, email));
} catch (JSONException e) {
Log.e(TAG, "JSON Exception reading from Facebook GraphRequest", e);
mCallbackObject.onFailure(new Bundle());
}
}
}
});
Expand Down