@less-is-more/less-js 1.4.13 → 1.4.14
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/router.js +9 -6
package/package.json
CHANGED
package/src/router.js
CHANGED
|
@@ -49,8 +49,7 @@ module.exports = class Router {
|
|
|
49
49
|
// controller方法有返回值的自动send
|
|
50
50
|
this._handleReturn(result, startTime, req, res);
|
|
51
51
|
} catch (e) {
|
|
52
|
-
|
|
53
|
-
return this._sendError(e.message ? e.message : "出错啦", res);
|
|
52
|
+
return this._sendError(e.message ? e.message : "出错啦", res, true);
|
|
54
53
|
}
|
|
55
54
|
} else {
|
|
56
55
|
return this._sendError("请输入正确方法", res);
|
|
@@ -100,7 +99,7 @@ module.exports = class Router {
|
|
|
100
99
|
try {
|
|
101
100
|
req.body = JSON.parse(data);
|
|
102
101
|
} catch (e) {
|
|
103
|
-
console.
|
|
102
|
+
console.warn("body格式错误", data);
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
} else {
|
|
@@ -160,14 +159,18 @@ module.exports = class Router {
|
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
|
|
163
|
-
static _sendError(message, res) {
|
|
164
|
-
|
|
162
|
+
static _sendError(message, res, errorLevel = false) {
|
|
163
|
+
if (errorLevel) {
|
|
164
|
+
console.warn(message);
|
|
165
|
+
} else {
|
|
166
|
+
console.error(message);
|
|
167
|
+
}
|
|
165
168
|
if (this.#defaultFormat) {
|
|
166
169
|
res.send(
|
|
167
170
|
new Ret(
|
|
168
171
|
false,
|
|
169
172
|
message,
|
|
170
|
-
message
|
|
173
|
+
/请输入|参数/.test(message) ? Ret.CODE_PARAMETER : Ret.CODE_SYSTEM
|
|
171
174
|
).toString()
|
|
172
175
|
);
|
|
173
176
|
}
|