64 lines
1.8 KiB
Java
64 lines
1.8 KiB
Java
package com.ubt.jimu.base.http;
|
|
|
|
import android.content.Context;
|
|
import com.ubt.jimu.R;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ApiResultException extends RuntimeException {
|
|
public static final int CODE_NET_WORK_ERROR = -1;
|
|
public static final int CODE_SYS_ERROR = -2;
|
|
private int code;
|
|
private String message;
|
|
|
|
public ApiResultException(int i, String str) {
|
|
this.code = i;
|
|
this.message = str;
|
|
}
|
|
|
|
public static String codeToMessage(Context context, int i) {
|
|
if (i == -1) {
|
|
return context.getString(R.string.network_error);
|
|
}
|
|
if (i == 2011) {
|
|
return context.getString(R.string.error_phone_format);
|
|
}
|
|
if (i == 2018) {
|
|
return context.getString(R.string.error_user_exist);
|
|
}
|
|
if (i == 2019) {
|
|
return context.getString(R.string.error_get_captcha);
|
|
}
|
|
switch (i) {
|
|
case 2002:
|
|
return context.getString(R.string.error_username_password);
|
|
case 2003:
|
|
return context.getString(R.string.error_user_exist);
|
|
case 2004:
|
|
return context.getString(R.string.error_user_not_found);
|
|
case 2005:
|
|
return context.getString(R.string.error_captcha);
|
|
case 2006:
|
|
return context.getString(R.string.error_account_captcha);
|
|
default:
|
|
return context.getString(R.string.error_system_later_try) + " (code: " + i + ")";
|
|
}
|
|
}
|
|
|
|
public int getCode() {
|
|
return this.code;
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
public String getMessage() {
|
|
return this.message;
|
|
}
|
|
|
|
public void setCode(int i) {
|
|
this.code = i;
|
|
}
|
|
|
|
public void setMessage(String str) {
|
|
this.message = str;
|
|
}
|
|
}
|