z-error
Version:
* verify: 校验字段有效性,合法性。检验不通过返回ZError对象,否则返回null * ZError: 错误提示,继承Error。name表示错误名称,code表示错误码,message表示code对应的提示信息,description错误描述。status表示restful api 状态码 * setLocal:设置多语言错误对照码
24 lines (22 loc) • 434 B
JavaScript
/*
* @Author: Zz
* @Date: 2017-06-26 09:05:57
* @Last Modified by: Zz
* @Last Modified time: 2017-06-26 09:51:12
*/
const config = require('./config');
exports.getMessage = (code, lang) => {
if(!code){
return '';
}
if (!config.errorTable[lang]) {
return '';
}
return config.errorTable[lang][code] || '';
}
exports.getErrCodeTable = (lang) => {
if (!lang) {
return null;
}
return config.errorTable[lang] || null;
}