@nocobase/plugin-error-handler 2.1.0-beta.45 → 2.1.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.45",
12
- "@nocobase/server": "2.1.0-beta.45",
11
+ "@nocobase/client": "2.1.0-beta.47",
12
+ "@nocobase/server": "2.1.0-beta.47",
13
13
  "lodash": "4.18.1"
14
14
  };
@@ -68,15 +68,23 @@ class ErrorHandler {
68
68
  try {
69
69
  await next();
70
70
  } catch (err) {
71
- ctx.log.error(err.message, { method: "error-handler", err: err.stack, cause: err.cause });
72
71
  if (err.statusCode) {
73
72
  ctx.status = err.statusCode;
74
73
  }
75
74
  self.renderError(err, ctx);
75
+ const logMethod = getLogMethod(err);
76
+ ctx.log[logMethod](err.message, { method: "error-handler", err: err.stack, cause: err.cause });
76
77
  }
77
78
  };
78
79
  }
79
80
  }
81
+ const logMethods = ["trace", "debug", "info", "warn", "error"];
82
+ function getLogMethod(err) {
83
+ if (logMethods.includes(err == null ? void 0 : err.logLevel)) {
84
+ return err.logLevel;
85
+ }
86
+ return "error";
87
+ }
80
88
  // Annotate the CommonJS export names for ESM import in node:
81
89
  0 && (module.exports = {
82
90
  ErrorHandler
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description.ru-RU": "Обработка ошибок и исключений приложения.",
7
7
  "description": "Handling application errors and exceptions.",
8
8
  "description.zh-CN": "处理应用程序中的错误和异常。",
9
- "version": "2.1.0-beta.45",
9
+ "version": "2.1.0-beta.47",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/error-handler",
@@ -28,5 +28,5 @@
28
28
  "url": "git+https://github.com/nocobase/nocobase.git",
29
29
  "directory": "packages/plugin-error-handler"
30
30
  },
31
- "gitHead": "42587115fc34c3eb01ef2b2549f1c998e5708318"
31
+ "gitHead": "bf8fc3790e3494c901b4d22861c5471a0d27c464"
32
32
  }