266 lines
10 KiB
Java
266 lines
10 KiB
Java
package com.facebook;
|
|
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
import com.facebook.internal.FacebookRequestErrorClassification;
|
|
import com.facebook.internal.FetchedAppSettings;
|
|
import com.facebook.internal.FetchedAppSettingsManager;
|
|
import com.facebook.internal.Utility;
|
|
import com.ubt.jimu.base.entities.Course;
|
|
import java.net.HttpURLConnection;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class FacebookRequestError implements Parcelable {
|
|
private static final String BODY_KEY = "body";
|
|
private static final String CODE_KEY = "code";
|
|
private static final String ERROR_CODE_FIELD_KEY = "code";
|
|
private static final String ERROR_CODE_KEY = "error_code";
|
|
private static final String ERROR_IS_TRANSIENT_KEY = "is_transient";
|
|
private static final String ERROR_KEY = "error";
|
|
private static final String ERROR_MESSAGE_FIELD_KEY = "message";
|
|
private static final String ERROR_MSG_KEY = "error_msg";
|
|
private static final String ERROR_REASON_KEY = "error_reason";
|
|
private static final String ERROR_SUB_CODE_KEY = "error_subcode";
|
|
private static final String ERROR_TYPE_FIELD_KEY = "type";
|
|
private static final String ERROR_USER_MSG_KEY = "error_user_msg";
|
|
private static final String ERROR_USER_TITLE_KEY = "error_user_title";
|
|
public static final int INVALID_ERROR_CODE = -1;
|
|
public static final int INVALID_HTTP_STATUS_CODE = -1;
|
|
private final Object batchRequestResult;
|
|
private final Category category;
|
|
private final HttpURLConnection connection;
|
|
private final int errorCode;
|
|
private final String errorMessage;
|
|
private final String errorRecoveryMessage;
|
|
private final String errorType;
|
|
private final String errorUserMessage;
|
|
private final String errorUserTitle;
|
|
private final FacebookException exception;
|
|
private final JSONObject requestResult;
|
|
private final JSONObject requestResultBody;
|
|
private final int requestStatusCode;
|
|
private final int subErrorCode;
|
|
static final Range HTTP_RANGE_SUCCESS = new Range(200, 299);
|
|
public static final Parcelable.Creator<FacebookRequestError> CREATOR = new Parcelable.Creator<FacebookRequestError>() { // from class: com.facebook.FacebookRequestError.1
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public FacebookRequestError createFromParcel(Parcel parcel) {
|
|
return new FacebookRequestError(parcel);
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.Creator
|
|
public FacebookRequestError[] newArray(int i) {
|
|
return new FacebookRequestError[i];
|
|
}
|
|
};
|
|
|
|
public enum Category {
|
|
LOGIN_RECOVERABLE,
|
|
OTHER,
|
|
TRANSIENT
|
|
}
|
|
|
|
private static class Range {
|
|
private final int a;
|
|
private final int b;
|
|
|
|
boolean a(int i) {
|
|
return this.a <= i && i <= this.b;
|
|
}
|
|
|
|
private Range(int i, int i2) {
|
|
this.a = i;
|
|
this.b = i2;
|
|
}
|
|
}
|
|
|
|
static FacebookRequestError checkResponseAndCreateError(JSONObject jSONObject, Object obj, HttpURLConnection httpURLConnection) {
|
|
int optInt;
|
|
String str;
|
|
String str2;
|
|
String str3;
|
|
String str4;
|
|
boolean z;
|
|
int i;
|
|
try {
|
|
if (jSONObject.has(Course.TYPE_BLOCKLY)) {
|
|
int i2 = jSONObject.getInt(Course.TYPE_BLOCKLY);
|
|
Object a = Utility.a(jSONObject, BODY_KEY, "FACEBOOK_NON_JSON_RESULT");
|
|
if (a != null && (a instanceof JSONObject)) {
|
|
JSONObject jSONObject2 = (JSONObject) a;
|
|
boolean z2 = true;
|
|
if (jSONObject2.has("error")) {
|
|
JSONObject jSONObject3 = (JSONObject) Utility.a(jSONObject2, "error", (String) null);
|
|
String optString = jSONObject3.optString("type", null);
|
|
String optString2 = jSONObject3.optString(ERROR_MESSAGE_FIELD_KEY, null);
|
|
i = jSONObject3.optInt(Course.TYPE_BLOCKLY, -1);
|
|
int optInt2 = jSONObject3.optInt(ERROR_SUB_CODE_KEY, -1);
|
|
str3 = jSONObject3.optString(ERROR_USER_MSG_KEY, null);
|
|
str4 = jSONObject3.optString(ERROR_USER_TITLE_KEY, null);
|
|
z = jSONObject3.optBoolean(ERROR_IS_TRANSIENT_KEY, false);
|
|
str2 = optString2;
|
|
optInt = optInt2;
|
|
str = optString;
|
|
} else {
|
|
if (!jSONObject2.has(ERROR_CODE_KEY) && !jSONObject2.has(ERROR_MSG_KEY) && !jSONObject2.has(ERROR_REASON_KEY)) {
|
|
str = null;
|
|
str2 = null;
|
|
str3 = null;
|
|
str4 = null;
|
|
i = -1;
|
|
optInt = -1;
|
|
z2 = false;
|
|
z = false;
|
|
}
|
|
String optString3 = jSONObject2.optString(ERROR_REASON_KEY, null);
|
|
String optString4 = jSONObject2.optString(ERROR_MSG_KEY, null);
|
|
int optInt3 = jSONObject2.optInt(ERROR_CODE_KEY, -1);
|
|
optInt = jSONObject2.optInt(ERROR_SUB_CODE_KEY, -1);
|
|
str = optString3;
|
|
str2 = optString4;
|
|
str3 = null;
|
|
str4 = null;
|
|
z = false;
|
|
i = optInt3;
|
|
}
|
|
if (z2) {
|
|
return new FacebookRequestError(i2, i, optInt, str, str2, str4, str3, z, jSONObject2, jSONObject, obj, httpURLConnection, null);
|
|
}
|
|
}
|
|
if (!HTTP_RANGE_SUCCESS.a(i2)) {
|
|
return new FacebookRequestError(i2, -1, -1, null, null, null, null, false, jSONObject.has(BODY_KEY) ? (JSONObject) Utility.a(jSONObject, BODY_KEY, "FACEBOOK_NON_JSON_RESULT") : null, jSONObject, obj, httpURLConnection, null);
|
|
}
|
|
}
|
|
} catch (JSONException unused) {
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static synchronized FacebookRequestErrorClassification getErrorClassification() {
|
|
synchronized (FacebookRequestError.class) {
|
|
FetchedAppSettings c = FetchedAppSettingsManager.c(FacebookSdk.c());
|
|
if (c == null) {
|
|
return FacebookRequestErrorClassification.a();
|
|
}
|
|
return c.d();
|
|
}
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public int describeContents() {
|
|
return 0;
|
|
}
|
|
|
|
public Object getBatchRequestResult() {
|
|
return this.batchRequestResult;
|
|
}
|
|
|
|
public Category getCategory() {
|
|
return this.category;
|
|
}
|
|
|
|
public HttpURLConnection getConnection() {
|
|
return this.connection;
|
|
}
|
|
|
|
public int getErrorCode() {
|
|
return this.errorCode;
|
|
}
|
|
|
|
public String getErrorMessage() {
|
|
String str = this.errorMessage;
|
|
return str != null ? str : this.exception.getLocalizedMessage();
|
|
}
|
|
|
|
public String getErrorRecoveryMessage() {
|
|
return this.errorRecoveryMessage;
|
|
}
|
|
|
|
public String getErrorType() {
|
|
return this.errorType;
|
|
}
|
|
|
|
public String getErrorUserMessage() {
|
|
return this.errorUserMessage;
|
|
}
|
|
|
|
public String getErrorUserTitle() {
|
|
return this.errorUserTitle;
|
|
}
|
|
|
|
public FacebookException getException() {
|
|
return this.exception;
|
|
}
|
|
|
|
public JSONObject getRequestResult() {
|
|
return this.requestResult;
|
|
}
|
|
|
|
public JSONObject getRequestResultBody() {
|
|
return this.requestResultBody;
|
|
}
|
|
|
|
public int getRequestStatusCode() {
|
|
return this.requestStatusCode;
|
|
}
|
|
|
|
public int getSubErrorCode() {
|
|
return this.subErrorCode;
|
|
}
|
|
|
|
public String toString() {
|
|
return "{HttpStatus: " + this.requestStatusCode + ", errorCode: " + this.errorCode + ", errorType: " + this.errorType + ", errorMessage: " + getErrorMessage() + "}";
|
|
}
|
|
|
|
@Override // android.os.Parcelable
|
|
public void writeToParcel(Parcel parcel, int i) {
|
|
parcel.writeInt(this.requestStatusCode);
|
|
parcel.writeInt(this.errorCode);
|
|
parcel.writeInt(this.subErrorCode);
|
|
parcel.writeString(this.errorType);
|
|
parcel.writeString(this.errorMessage);
|
|
parcel.writeString(this.errorUserTitle);
|
|
parcel.writeString(this.errorUserMessage);
|
|
}
|
|
|
|
private FacebookRequestError(int i, int i2, int i3, String str, String str2, String str3, String str4, boolean z, JSONObject jSONObject, JSONObject jSONObject2, Object obj, HttpURLConnection httpURLConnection, FacebookException facebookException) {
|
|
boolean z2;
|
|
this.requestStatusCode = i;
|
|
this.errorCode = i2;
|
|
this.subErrorCode = i3;
|
|
this.errorType = str;
|
|
this.errorMessage = str2;
|
|
this.requestResultBody = jSONObject;
|
|
this.requestResult = jSONObject2;
|
|
this.batchRequestResult = obj;
|
|
this.connection = httpURLConnection;
|
|
this.errorUserTitle = str3;
|
|
this.errorUserMessage = str4;
|
|
if (facebookException != null) {
|
|
this.exception = facebookException;
|
|
z2 = true;
|
|
} else {
|
|
this.exception = new FacebookServiceException(this, str2);
|
|
z2 = false;
|
|
}
|
|
FacebookRequestErrorClassification errorClassification = getErrorClassification();
|
|
this.category = z2 ? Category.OTHER : errorClassification.a(i2, i3, z);
|
|
this.errorRecoveryMessage = errorClassification.a(this.category);
|
|
}
|
|
|
|
FacebookRequestError(HttpURLConnection httpURLConnection, Exception exc) {
|
|
this(-1, -1, -1, null, null, null, null, false, null, null, null, httpURLConnection, exc instanceof FacebookException ? (FacebookException) exc : new FacebookException(exc));
|
|
}
|
|
|
|
public FacebookRequestError(int i, String str, String str2) {
|
|
this(-1, i, -1, str, str2, null, null, false, null, null, null, null, null);
|
|
}
|
|
|
|
private FacebookRequestError(Parcel parcel) {
|
|
this(parcel.readInt(), parcel.readInt(), parcel.readInt(), parcel.readString(), parcel.readString(), parcel.readString(), parcel.readString(), false, null, null, null, null, null);
|
|
}
|
|
}
|