package cd.casic.ci.repository.enums;


import cd.casic.framework.commons.exception.ErrorCode;
import cd.casic.framework.commons.pojo.CommonResult;

public enum RepositoryExceptionEnum {

    /**
     * 数据不存在
     */
    NOT_EXIST(1, "此数据不存在"),
    NODE_EXIST(2, "该节点信息已存在"),
    NOT_EXIST_PIPELINE(3, "该流水线不存在"),
    GIT_REMOTE_CONNECT_ERROR(4, "获取分支失败"),
    VCS_CLONE_ERROR(5, "仓库克隆失败"),
    VCS_PATH_ABSENT(6, "仓库目录不存在"),
    VCS_UNABLE_CONNECT(7, "无法连接到远程仓库,请检查用户名或密码"),
    VCS_UNINITIALIZED(8, "仓库未初始化"),
    VCS_INITIALIZED(9, "远程仓库已初始化"),
    VCS_INITIALIZING(10, "远程仓库初始化中"),
    NODE_EXECUTE_FAIL(11, "节点执行失败"),
    NOT_EXIST_START(12, "请先添加开始节点"),
    GIT_USER_OR_PWD_IS_NONE(13, "用户名密码为不能为空"),
    GIT_INVALID_URL_ERROR(14, "无效的仓库URL地址，或者网络故障问题");

    private final Integer code;

    private final String message;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    RepositoryExceptionEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    public static ErrorCode getErrorCode(RepositoryExceptionEnum rx){
        return new ErrorCode(rx.getCode(), rx.message);
    }
}
