@nocobase/plugin-error-handler 2.0.0-alpha.53 → 2.0.0-alpha.54

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,9 +8,9 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.0.0-alpha.53",
11
+ "@nocobase/client": "2.0.0-alpha.54",
12
12
  "@formily/json-schema": "2.3.7",
13
- "@nocobase/database": "2.0.0-alpha.53",
14
- "@nocobase/server": "2.0.0-alpha.53",
13
+ "@nocobase/database": "2.0.0-alpha.54",
14
+ "@nocobase/server": "2.0.0-alpha.54",
15
15
  "lodash": "4.17.21"
16
16
  };
@@ -88,6 +88,27 @@ class PluginErrorHandlerServer extends import_server.Plugin {
88
88
  ctx.status = 400;
89
89
  }
90
90
  );
91
+ this.errorHandler.register(
92
+ (err) => {
93
+ const e = (err == null ? void 0 : err.original) || err;
94
+ if ((e == null ? void 0 : e.errno) === 1064) return true;
95
+ if ((e == null ? void 0 : e.code) === "42601") return true;
96
+ if ((e == null ? void 0 : e.code) === "SQLITE_ERROR" && /syntax error/i.test(e == null ? void 0 : e.message)) {
97
+ return true;
98
+ }
99
+ return false;
100
+ },
101
+ (err, ctx) => {
102
+ ctx.body = {
103
+ errors: [
104
+ {
105
+ message: "Invalid SQL syntax"
106
+ }
107
+ ]
108
+ };
109
+ ctx.status = 500;
110
+ }
111
+ );
91
112
  }
92
113
  async load() {
93
114
  this.app.use(this.errorHandler.middleware(), { after: "i18n", tag: "errorHandler", before: "cors" });
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.0.0-alpha.53",
9
+ "version": "2.0.0-alpha.54",
10
10
  "license": "AGPL-3.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": "ff30cf8261f5a97b3f24c3752af5bbc564167b37"
31
+ "gitHead": "68c84deaabba0ebec7407bf7245376b8d843449c"
32
32
  }