|
@@ -141,6 +141,10 @@ nextId : string //下一行id
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
+// process.on('uncaughtException', (e) => {
|
|
|
+// console.error('process error is:', e.message);
|
|
|
+// });
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 创建服务
|
|
@@ -402,23 +406,39 @@ us.unifyDispose = function (req, res, cb) {
|
|
|
|
|
|
//请求超时处理
|
|
|
res.on('timeout', function (e) {
|
|
|
- console.log('请求超时'); //错误消息的输出
|
|
|
- if (req.res) {
|
|
|
- req.res("abort");
|
|
|
+ try {
|
|
|
+ console.log('请求超时'); //错误消息的输出
|
|
|
+ if (req.res) {
|
|
|
+ req.res("abort");
|
|
|
+ }
|
|
|
+ res.end("false"); //返回值
|
|
|
}
|
|
|
- res.end("false"); //返回值
|
|
|
+ catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
|
|
|
//设置30秒后超时
|
|
|
res.setTimeout(30000, function () {
|
|
|
- console.log("响应超时.");
|
|
|
- res.end("false"); //返回值
|
|
|
+ try {
|
|
|
+ console.log("响应超时.");
|
|
|
+ res.end("false"); //返回值
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
//错误处理
|
|
|
req.on("error", function (e) {
|
|
|
- console.log('程序报错');
|
|
|
- res.end("false");
|
|
|
+ try {
|
|
|
+ console.log('程序报错');
|
|
|
+ res.end("false");
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
|