package com.sobot.network.http.exception;


/**
 * 网络异常
 */
public class StHttpException extends RuntimeException {
    private static final long serialVersionUID = 8773734741709178425L;

    private int code;                               //HTTP status code
    private String message;                         //HTTP status message
//    private transient Response<?> response;         //The full HTTP response. This may be null if the exception was serialized

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

    /*public StHttpException(Response<?> response) {
        super(getMessage(response));
        this.code = response.code();
        this.message = response.message();
        this.response = response;
    }

    private static String getMessage(Response<?> response) {
//        HttpUtils.checkNotNull(response, "response == null");
        return "HTTP " + response.code() + " " + response.message();
    }*/

    public int code() {
        return code;
    }

    public String message() {
        return message;
    }

//    public Response<?> response() {
//        return response;
//    }

    public static StHttpException NET_ERROR() {
        return new StHttpException("network error! http response code is 404 or 5xx!");
    }

    public static StHttpException COMMON(String message) {
        return new StHttpException(message);
    }
}
