UNPKG

@yhiot/utils

Version:
59 lines (48 loc) 1.5 kB
export const EC = { ERR_SYSTEM_ERROR: -1, ERR_OK: 0, ERR_UNAUTH: 401, ERR_UNKNOWN: 4001, ERR_BUSY: 4002, ERR_PARAM_ERROR: 4003, ERR_NO_SUCH_API: 4004, ERR_3RD_API_FAIL: 4005, ERR_NO_SUCH_ENTITY: 40004, ERR_ALREADY_EXIST: 40007, ERR_DB_ENTITY_DAMAGE: 40009, ERR_SMS_FAIL: 40011, ERR_SMS_LIMIT_CONTROL: 40012, ERR_SMS_DAY_LIMIT_CONTROL: 40013, ERR_SMS_MONTH_LIMIT_CONTROL: 40014, ERR_AUTH_NOT_REGIST_PHONE: 410201, ERR_AUTH_WRONG_PASSWORD: 410202, ERR_AUTH_SMSCODE_NONE: 410203, ERR_AUTH_SMSCODE_MISMATCH: 410204, ERR_AUTH_USER_MISMATCH: 410205, ERR_AUTH_WXSTATE_NONE: 410206, ERR_AUTH_WXSTATE_EXPIRE: 410207, ERR_AUTH_NO_SUCH_USERNAME: 410208, ERR_CTWING_PAYLOAD_PARSE_FAIL: 410401, ERR_CTWING_NOT_ALLOW_X_PRODUCT: 410402, ERR_PULSAR_NETWORK_FAIL: 412001, ERR_PULSAR_OP_FAIL: 412002, ERR_PULSAR_OP_CONFLICT: 412009, ERR_IOT_NOT_ALLOW_X_PRODUCT: 410301, }; export const EM = require('./Errcode.cn').default(EC); export function Errcode(message, errcode = -1) { this.name = 'Errcode'; this.message = message || ''; this.errcode = errcode; if (typeof Error.captureStackTrace === 'function') { Error.captureStackTrace(this, this.constructor); } else { this.stack = new Error(errcode + ':' + message).stack; } this.toJSON = () => { return { errcode: this.errcode, msg: this.message }; }; } Errcode.prototype = Object.create(Error.prototype); // Errcode.prototype.constructor = Errcode; export default Errcode;