@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 +1 -1
- package/src/param.js +1 -1
- package/src/router.js +7 -1
- package/test/test-router.js +4 -4
package/package.json
CHANGED
package/src/param.js
CHANGED
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(
|
|
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
|
}
|
package/test/test-router.js
CHANGED
|
@@ -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 = {
|