package com.sjyt.icom.asst.common.enums;

import cn.hutool.core.util.ObjectUtil;
import com.sjyt.icom.asst.common.exception.ErrorCodeException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * <p>错误码</p>
 *
 * @author renyanru
 * @version V1.0.0
 * @date 2022/6/21 10:52
 */
@Getter
@AllArgsConstructor
public enum ErrorCodeEnum{
    //业务层
    REQ_PARAM_ERROR("10001","参数格式错误"),
    REQ_BUSY_ERROR("10002","对方正在通话中"),
    //RPC层调用
    UNKNOWN_SDP_ERROR("20000","sdp交换失败"),
    UNKNOWN_ERROR("20001","网络异常");

    public final String CODE;
    public final String VALUE;
    public static ErrorCodeEnum of(String code) {
        ErrorCodeEnum[] values = ErrorCodeEnum.values();
        for (ErrorCodeEnum value : values) {
            if (ObjectUtil.equals(code, value.CODE)) {
                return value;
            }
        }
        throw new ErrorCodeException("错误码异常");
    }
}
