package net.geedge.common;

import java.text.MessageFormat;

public enum RCode {


    BAD_REQUEST(400, "Bad Request "),

    NOT_EXISTS(404, "No such file or directory"),
    NOT_PERMISSION(401 , "Permission denied"),
    TIMEOUT(408, "Request Timeout"),

    ERROR(999, "error"), // 通用错误/未知错误

    SUCCESS(200, "success"); // 成功

    RCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private Integer code;
    private String msg;
    private Object[] param;

    public RCode setParam(Object... param) {
        this.param = param;
        return this;
    }

    public Object[] getParam() {
        return param;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return MessageFormat.format(msg, param);
    }
}