UNPKG

erest

Version:

Easy to build api server depend on @leizm/web and express.

30 lines (29 loc) 915 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = errorDocs; const utils_1 = require("./utils"); function errorString(item) { return (0, utils_1.fieldString)([ (0, utils_1.stringOrEmpty)(item.name, true), String(item.code), (0, utils_1.stringOrEmpty)(item.description), (0, utils_1.itemTF)(item.isShow), (0, utils_1.itemTF)(item.isLog), ]); } function errorDocs(data) { const errors = []; data.errorManager.forEach((value) => { errors.push(value); }); errors.sort((a, b) => { return b.code - a.code; }); const errorList = []; errorList.push("# 错误类型"); errorList.push((0, utils_1.tableHeader)(["错误", "错误码", "描述", "显示", "日志"])); for (const item of errors) { errorList.push(errorString(item)); } return errorList.join("\n"); }