枚举 异常信息

/**
 *  使用枚举类型来封装异常码和异常信息
 * @author zhength
 * @version 1.0.0
 * @email [email protected]
 * @date 2018/9/12 16:33
 * @since 1.8
 */
 public enum ErrorCodeMsg {
        //RPC层调用错误码
         OK(20100,"服务正常")
        ,UNKNOWN_ERROR(500,"未知异常")
        ,DBDAO_ERROR(20104,"返回数据库的具体异常信息")

        ,SPEAKER_NOT_EXISTED(20108,"数据库中没有要查询的speaker")
        ,SPEAKER_HAVE_NOT_VP(20109,"speaker中没有对应的voiceprint")
        ,AGENT_ERROR   (20102,    "DBServiceAgent异常")
        ,NETWORK_ERROR (20103,"网络异常")

        ,INVALID_FUNCTION(20105,   "方法名不存在")
        ,INVALID_PARAMETER(20106,"方法参数错误")
        ,FUNCTION_NO_ACCESS(20107,"对此方法无访问权限");

        private String msg;
        private int code;

        private ErrorCodeMsg(int code,String msg)
        {
            this.code=code;
            this.msg=msg;
        }

        public String getMsg()
        {
            return this.msg;
        }
        public int getCode() {
            return this.code;
        }

    }

你可能感兴趣的:(枚举 异常信息)