UNPKG

892 BJavaScriptView Raw
1"use strict";
2class Exception extends Error {
3 constructor({ code = "000", msg = "程序异常", level = "error" }) {
4 super(msg);
5 this.name = "Exception";
6 this.level = level;
7 this.code = code;
8 this.msg = msg;
9 Error.captureStackTrace(this, this.constructor);
10 const errorToLogMap = {
11 info: () => bun.Logger.info(this.stack),
12 debug: () => bun.Logger.debug(this.stack),
13 error: () => bun.Logger.error(this.stack),
14 warn: () => bun.Logger.warn(this.stack),
15 fatal: () => bun.Logger.fatal(this.stack),
16 bunwarn: () => bun.Logger.bunwarn(this.stack),
17 bunerr: () => bun.Logger.bunerr(this.stack),
18 };
19 errorToLogMap[level]();
20 }
21 toString() {
22 return this.msg;
23 }
24}
25module.exports = Exception;
26//# sourceMappingURL=Exception.js.map
\No newline at end of file