我目前正在研究用 node.js 编写的 TS3 查询机器人。我添加了一个自动重新连接到它,但我现在遇到的问题是,如果服务器脱机并出现以下错误,机器人会崩溃:
events.js:85
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:983:19)
Run Code Online (Sandbox Code Playgroud)
开始连接的行如下:
var cl = new ts3.TeamSpeakClient(config.serverIP);
Run Code Online (Sandbox Code Playgroud)
与 node-ts api 一起使用 -> https://github.com/nikeee/node-ts
我已经添加了以下事件:
cl.on('error', function(err){
console.log("bla: " + err)
});
cl.on('uncaughtException', function (err) {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
uncaughtException 不会被触发,错误也不会阻止崩溃。
我怎样才能防止它崩溃?
编辑:顺便说一句,这是异步的。
有没有办法继承现有的自定义语法?因为我想要自定义语法,但不想从零开始。
我已经找到了这个:How do I add features to a syntaxdefin in Sublime Text without edit it? 但我无法让它工作,因为它没有详细解释。
如果这是不可能的,我在哪里可以找到 Go 语言语法的文件?