Skip to content

Commit

Permalink
Use AuthFailureError instead of checking the error code 403 manually.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloercoli committed Jul 8, 2015
1 parent d1bb8cb commit a39892a
Showing 1 changed file with 7 additions and 12 deletions.
Expand Up @@ -403,18 +403,13 @@ public void run() {

// Check here if this is an authentication error
// .com authentication errors are handled automatically by the app
if (volleyError.networkResponse != null) {
NetworkResponse networkResponse = volleyError.networkResponse;
if (networkResponse.statusCode == 403 && networkResponse.data != null) {
if (new String(networkResponse.data).contains("unauthorized")) {
int localId = WordPress.wpDB.getLocalTableBlogIdForRemoteBlogId(
Integer.parseInt(mRequestBlogId)
);
Blog blog = WordPress.wpDB.instantiateBlogByLocalId(localId);
if (blog != null && blog.isJetpackPowered()) {
EventBus.getDefault().post(new StatsEvents.JetpackAuthError(localId));
}
}
if (volleyError instanceof com.android.volley.AuthFailureError) {
int localId = WordPress.wpDB.getLocalTableBlogIdForRemoteBlogId(
Integer.parseInt(mRequestBlogId)
);
Blog blog = WordPress.wpDB.instantiateBlogByLocalId(localId);
if (blog != null && blog.isJetpackPowered()) {
EventBus.getDefault().post(new StatsEvents.JetpackAuthError(localId));
}
}
mResponseObjectModel = volleyError;
Expand Down

0 comments on commit a39892a

Please sign in to comment.