@nocobase/plugin-error-handler 0.19.0-alpha.9 → 0.20.0-alpha.2

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.
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- "@nocobase/client": "0.19.0-alpha.9",
2
+ "@nocobase/client": "0.20.0-alpha.2",
3
3
  "@formily/json-schema": "2.3.0",
4
- "@nocobase/database": "0.19.0-alpha.9",
5
- "@nocobase/server": "0.19.0-alpha.9",
4
+ "@nocobase/database": "0.20.0-alpha.2",
5
+ "@nocobase/server": "0.20.0-alpha.2",
6
6
  "lodash": "4.17.21"
7
7
  };
@@ -44,12 +44,15 @@ class PluginErrorHandler extends import_server.Plugin {
44
44
  this.registerSequelizeValidationErrorHandler();
45
45
  }
46
46
  registerSequelizeValidationErrorHandler() {
47
- const findFieldTitle = (instance, path, tFunc) => {
47
+ const findFieldTitle = (instance, path, tFunc, ctx) => {
48
48
  if (!instance) {
49
49
  return path;
50
50
  }
51
51
  const model = instance.constructor;
52
- const collection = this.db.modelCollection.get(model);
52
+ const dataSourceKey = ctx.get("x-data-source");
53
+ const dataSource = ctx.app.dataSourceManager.dataSources.get(dataSourceKey);
54
+ const database = dataSource ? dataSource.collectionManager.db : ctx.db;
55
+ const collection = database.modelCollection.get(model);
53
56
  const field = collection.getField(path);
54
57
  const fieldOptions = import_json_schema.Schema.compile(field == null ? void 0 : field.options, { t: tFunc });
55
58
  const title = import_lodash.default.get(fieldOptions, "uiSchema.title", path);
@@ -66,7 +69,7 @@ class PluginErrorHandler extends import_server.Plugin {
66
69
  return {
67
70
  message: ctx.i18n.t(err2.type, {
68
71
  ns: this.i18nNs,
69
- field: findFieldTitle(err2.instance, err2.path, ctx.i18n.t)
72
+ field: findFieldTitle(err2.instance, err2.path, ctx.i18n.t, ctx)
70
73
  })
71
74
  };
72
75
  })
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "错误处理器",
5
5
  "description": "Handling application errors and exceptions.",
6
6
  "description.zh-CN": "处理应用程序中的错误和异常。",
7
- "version": "0.19.0-alpha.9",
7
+ "version": "0.20.0-alpha.2",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -23,5 +23,5 @@
23
23
  "url": "git+https://github.com/nocobase/nocobase.git",
24
24
  "directory": "packages/plugin-error-handler"
25
25
  },
26
- "gitHead": "975f9c58a1995df6a8d7a4d191a0dc4a9769ebc5"
26
+ "gitHead": "6fb885dfc3554e4b0f29e9a7a1eecbbe85d0eebb"
27
27
  }