001/*
002 * ===========================================================================================
003 * = COPYRIGHT
004 *          PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
005 *   This software is supplied under the terms of a license agreement or nondisclosure
006 *   agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or
007 *   disclosed except in accordance with the terms in that agreement.
008 *     Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved.
009 * Description: // Detail description about the function of this module,
010 *             // interfaces with the other modules, and dependencies.
011 * Revision History:
012 * Date                         Author                        Action
013 * 2017/04/01                   PAX                     Create/Add/Modify/Delete
014 * ===========================================================================================
015 */
016package com.pax.dal.exceptions;
017
018import com.pax.dal.utils.Utils;
019
020/**
021 * <div class="zh">网络异常类。</div>
022 * <div class="en">Network exception.</div>
023 */
024public enum ENetworkException {
025    /**
026     * <div class="zh"> 未知异常 </div> <div class="en"> unexpected error </div>
027     */
028    DEVICES_ERR_UNEXPECTED(97, "unexpected error", "未知异常"),
029
030    /**
031     * <div class="zh"> 参数错误 </div> <div class="en"> invalid argument error </div>
032     */
033    DEVICES_ERR_INVALID_ARGUMENT(98, "invalid argument error", "参数错误"),
034    /**
035     * <div class="zh"> RPC I/O 连接异常 </div> <div class="en"> connect error </div>
036     */
037    DEVICES_ERR_CONNECT(99, "connect error", "RPC I/O 连接异常"),
038
039    /**
040     * <div class="zh"> 不支持 </div> <div class="en"> not support error </div>
041     */
042    DEVICES_ERR_NO_SUPPORT(100, "not support error", "不支持"),
043
044    /**
045     * <div class="zh"> 无权限异常</div> <div class="en"> no permission error </div>
046     */
047    DEVICES_ERR_NO_PERMISSION(101, "no permission error", "无权限异常"),
048
049    /**
050     * <div class="zh"> 服务不可用。 </div> <div class="en"> Service not available. </div>
051     */
052    SERVICE_NOT_AVAILABLE(1, "Service not available", "服务不可用"),
053
054    /**
055     * <div class="zh">执行规则失败</div> <div class="en">Failed to execute the rule</div>
056     */
057    NETWORK_EXECUTE_FAIL(-1, "Failed to execute the rule", "执行规则失败"),
058
059    /**
060     * <div class="zh">设备不支持白名单模式</div> <div class="en">This device does not support white list mode</div>
061     */
062    NO_SUPPORT_WHITELIST_MODE(-10, "This device does not support white list mode", "未知异常"),
063
064    /**
065     * <div class="zh">设备已经是白名单模式</div> <div class="en">This device already in white list mode</div>
066     */
067    ERR_ALREADY_WHITELIST_MODE(-11, "This device already in white list mode", "设备已经是白名单模式"),
068
069    /**
070     * <div class="zh">设备不是白名单模式</div> <div class="en">This device not in white list mode</div>
071     */
072    ERR_NOT_WHITELIST_MODE(-12, "This device not in white list mode", "设备不是白名单模式"),
073
074    /**
075     * <div class="zh">设备已经是客户白名单模式</div> <div class="en">This device already in customer white list mode</div>
076     */
077    ERR_ALREADY_CUS_WHITELIST_MODE(-21, "This device already in customer white list mode", "设备已经是客户白名单模式"),
078
079    /**
080     * <div class="zh">设备不是客户白名单模式</div> <div class="en">This device not in customer white list mode</div>
081     */
082    ERR_NOT_CUS_WHITELIST_MODE(-22, "This device not in customer white list mode", "设备不是客户白名单模式"),
083
084    /**
085     * <div class="zh">创建socket错误</div> <div class="en">Socket creation error</div>
086     */
087    CREATE_SOCKET_ERROR(-3, "This device not in customer white list mode", "创建socket错误"),
088
089    /**
090     * <div class="zh">设备不是客户白名单模式</div> <div class="en">This device not in customer white list mode</div>
091     */
092    CREATE_SSLFACTORY_ERROR(-2, "This device not in customer white list mode", "创建SSLFactory错误"),
093
094    /**
095     * <div class="zh">创建URLConnection错误</div> <div class="en">Error creating URLConnection</div>
096     */
097    CREATE_URLCONNECTION_ERROR(-4, "This device not in customer white list mode", "创建URLConnection错误"),
098
099    /**
100     * <div class="zh">host不在网络白名单</div> <div class="en">host is not in the network whitelist</div>
101     */
102    HOST_NOT_IN_WHITE_LIST(-1, "Host is not in the network whitelist", "host不在网络白名单"),
103
104    /**
105     * <div class="zh">无调用权限</div> <div class="en">No call permission</div>
106     */
107    NO_PERMISSION_CALL_ERROR(-52, "No call permission", "无调用权限"),
108
109    /**
110     * <div class="zh">证书链校验错误</div> <div class="en">The certificate chain verification error</div>
111     */
112    CERT_CHECK_ERROR(-101, "The certificate chain verification error", "证书链校验错误")
113    ;
114
115    private final int errCodeFromBasement;
116    private final String errMsgCn;
117    private final String errMsgEn;
118
119    ENetworkException(int errCodeFromBasement, String errMsgEn, String errMsnCn) {
120        this.errCodeFromBasement = errCodeFromBasement;
121        this.errMsgCn = errMsnCn;
122        this.errMsgEn = errMsgEn;
123    }
124
125    public int getErrCodeFromBasement() {
126        return errCodeFromBasement;
127    }
128
129    public String getErrMsg() {
130        if (Utils.isZh()) {
131            return errMsgCn;
132        } else {
133            return errMsgEn;
134        }
135    }
136}