报错处理

This commit is contained in:
fofolee 2022-04-18 08:56:10 +08:00
parent 05999db5d2
commit ebd2ebddae
2 changed files with 37 additions and 30 deletions

View File

@ -527,7 +527,7 @@ window.runCodeInVm = (cmd, callback, userVars = {}) => {
let liteErr = e => { let liteErr = e => {
if (!e) return if (!e) return
return e.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() return e.error ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() : e.message
} }
// 错误处理 // 错误处理
@ -541,7 +541,7 @@ window.runCodeInVm = (cmd, callback, userVars = {}) => {
let cbUnhandledError = e => { let cbUnhandledError = e => {
removeAllListener() removeAllListener()
console.log('UnhandledError: ', e) console.log('UnhandledError: ', e)
callback(null, liteErr(e.error)) callback(null, liteErr(e))
} }
let cbUnhandledRejection = e => { let cbUnhandledRejection = e => {
@ -662,6 +662,9 @@ window.quickcommandHttpServer = () => {
} }
}) })
httpServer.listen(port, 'localhost'); httpServer.listen(port, 'localhost');
httpServer.on('error', err => {
console.log(err)
})
} }
let stop = () => { let stop = () => {
httpServer.close() httpServer.close()

View File

@ -33,18 +33,7 @@ export default defineComponent({
}); });
return; return;
} }
// this.startUp();
if (this.$profile.quickFeatures.apiServer.serverStatus) {
window
.quickcommandHttpServer()
.run(
this.$profile.quickFeatures.apiServer.cmd,
this.$profile.quickFeatures.apiServer.port
);
console.log("Server Start...");
}
//
this.setCssVar("primary", this.$profile.primaryColor);
// //
utools.onPluginEnter((enter) => { utools.onPluginEnter((enter) => {
// //
@ -76,6 +65,21 @@ export default defineComponent({
this.$utools.DBPRE.CFG + "preferences" this.$utools.DBPRE.CFG + "preferences"
); );
}, },
//
startUp() {
//
if (this.$profile.quickFeatures.apiServer.serverStatus) {
window
.quickcommandHttpServer()
.run(
this.$profile.quickFeatures.apiServer.cmd,
this.$profile.quickFeatures.apiServer.port
);
console.log("Server Start...");
}
//
this.setCssVar("primary", this.$profile.primaryColor);
},
}, },
}); });
</script> </script>