package com.bxzk.afxj.retrofit;

/**
 * Created by 「Sunyata」  on 2017/10/16   21:57.
 * <p>
 * Fws -> ApiException
 * <p>
 * God bless me only
 */


public class ApiException extends RuntimeException {
    public static final int CODE_TIMEOUT = 1000;
    public static final int CODE_UNCONNECTED = 1001;
    public static final int CODE_MALFORMJSON = 1020;
    public static final int CODE_OTHER = 1003;
    public static final String CONNECT_EXCEPTION = "网络连接超时，请检查您的网络状";
    public static final String SOCKET_TIMEOUT_EXCEPTION = "网络连接超时，请检查您的网络状态，稍后重试";
    public static final String MALFORMED_JSON_EXCEPTION = "访问失败，稍后重试";
    public static final String MALFORMED_JSON_EXCEPTIO = "返回数据问题，解析失败";
    private int resultCode;

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public ApiException(int resultCode, String msg) {

        this(getApiExceptionMessage(resultCode, msg));
        this.resultCode = resultCode;
    }

    public ApiException(String message) {
        super(message);
    }

    public static String getApiExceptionMessage(int code, String msg) {
        String message = "";
        switch (code) {
            default:
                message = msg;
        }

        return message;

    }
}
