@nocobase/plugin-error-handler 0.8.0-alpha.9 → 0.8.1-alpha.3

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.
@@ -48,6 +48,8 @@ class ErrorHandler {
48
48
  try {
49
49
  yield next();
50
50
  } catch (err) {
51
+ ctx.log.error(err);
52
+
51
53
  var _iterator = _createForOfIteratorHelper(self.handlers),
52
54
  _step;
53
55
 
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  'unique violation': string;
3
- 'notNull Violation': string;
3
+ 'notNull violation': string;
4
+ 'Validation error': string;
4
5
  };
5
6
  export default _default;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _default = {
8
8
  'unique violation': '{{field}} 字段值是唯一的',
9
- 'notNull Violation': '{{field}} 字段不能为空'
9
+ 'notNull violation': '{{field}} 字段不能为空',
10
+ 'Validation error': '{{field}} 字段规则验证失败'
10
11
  };
11
12
  exports.default = _default;
package/lib/server.js CHANGED
@@ -114,7 +114,10 @@ class PluginErrorHandler extends _server().Plugin {
114
114
 
115
115
  _this.app.i18n.addResources('en-US', _this.i18nNs, _en_US.default);
116
116
 
117
- _this.app.middleware.nodes.unshift(_this.errorHandler.middleware());
117
+ _this.app.use(_this.errorHandler.middleware(), {
118
+ before: 'cors',
119
+ tag: 'errorHandler'
120
+ });
118
121
  })();
119
122
  }
120
123
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-error-handler",
3
- "version": "0.8.0-alpha.9",
3
+ "version": "0.8.1-alpha.3",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -13,12 +13,12 @@
13
13
  "types": "./lib/index.d.ts",
14
14
  "dependencies": {
15
15
  "@formily/json-schema": "^2.0.15",
16
- "@nocobase/server": "0.8.0-alpha.9"
16
+ "@nocobase/server": "0.8.1-alpha.3"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",
20
20
  "url": "git+https://github.com/nocobase/nocobase.git",
21
21
  "directory": "packages/plugin-error-handler"
22
22
  },
23
- "gitHead": "6afe02d59bb22df0f96a7605c9001dcc17a30d6a"
23
+ "gitHead": "e03df3df5962b99d9fbf5b6e33fbe2b23f14f3d3"
24
24
  }
@@ -18,6 +18,7 @@ export class ErrorHandler {
18
18
  },
19
19
  ],
20
20
  };
21
+
21
22
  if (ctx.status === 500) {
22
23
  console.error(err);
23
24
  }
@@ -29,6 +30,8 @@ export class ErrorHandler {
29
30
  try {
30
31
  await next();
31
32
  } catch (err) {
33
+ ctx.log.error(err);
34
+
32
35
  for (const handler of self.handlers) {
33
36
  if (handler.guard(err)) {
34
37
  return handler.render(err, ctx);
@@ -1,4 +1,5 @@
1
1
  export default {
2
2
  'unique violation': '{{field}} 字段值是唯一的',
3
- 'notNull Violation': '{{field}} 字段不能为空',
3
+ 'notNull violation': '{{field}} 字段不能为空',
4
+ 'Validation error': '{{field}} 字段规则验证失败',
4
5
  };
package/src/server.ts CHANGED
@@ -49,6 +49,6 @@ export class PluginErrorHandler extends Plugin {
49
49
  async load() {
50
50
  this.app.i18n.addResources('zh-CN', this.i18nNs, zhCN);
51
51
  this.app.i18n.addResources('en-US', this.i18nNs, enUS);
52
- this.app.middleware.nodes.unshift(this.errorHandler.middleware());
52
+ this.app.use(this.errorHandler.middleware(), { before: 'cors', tag: 'errorHandler' });
53
53
  }
54
54
  }