@less-is-more/less-js 1.4.6 → 1.4.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@less-is-more/less-js",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Fast develop kit for nodejs",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/param.js CHANGED
@@ -37,7 +37,7 @@ module.exports = class Param {
37
37
  }
38
38
  }
39
39
  if (!result) {
40
- throw new Error(nCheck[3]);
40
+ throw new Error("参数:" + nCheck[3]);
41
41
  }
42
42
  });
43
43
  }
package/src/router.js CHANGED
@@ -157,7 +157,13 @@ module.exports = class Router {
157
157
  static _sendError(message, res) {
158
158
  console.log("error:", message);
159
159
  if (this.#defaultFormat) {
160
- res.send(new Ret(false, message, Ret.CODE_SYSTEM).toString());
160
+ res.send(
161
+ new Ret(
162
+ false,
163
+ message,
164
+ message.includes("参数:") ? Ret.CODE_PARAMETER : Ret.CODE_SYSTEM
165
+ ).toString()
166
+ );
161
167
  }
162
168
  return message;
163
169
  }
@@ -47,22 +47,22 @@ describe("router.js", () => {
47
47
  };
48
48
  Router.route(targets, req, res);
49
49
  });
50
- it("error", () => {
50
+ it("error", async () => {
51
51
  let targets = {
52
52
  "/": {
53
53
  add: function (req, res) {
54
- throw new Error("出错啦");
54
+ throw new Error("参数:出错啦");
55
55
  },
56
56
  },
57
57
  };
58
- let req = { path: "/add" };
58
+ let req = { path: "/add", headers: [] };
59
59
  let res = {
60
60
  send: function (data) {
61
61
  console.log("send: " + data);
62
62
  assert(JSON.parse(data).success == false);
63
63
  },
64
64
  };
65
- Router.route(targets, req, res);
65
+ await Router.route(targets, req, res);
66
66
  });
67
67
  it("multi controllers", () => {
68
68
  let targets = {