diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-11-12 11:29:46 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-11-12 11:29:46 +0800 |
commit | 812180e032c0149f0d96c00d418df3e4f9dc8c09 (patch) | |
tree | c71cf89ceba51a16f34baea6d2a45490a281ab56 /script-beta/brave | |
parent | 9adba2607bfd7b10879492ceb7b8926723bf40d3 (diff) | |
download | lua-language-server-812180e032c0149f0d96c00d418df3e4f9dc8c09.zip |
#250 协议解析失败后通知主线程,由主线程来退出
Diffstat (limited to 'script-beta/brave')
-rw-r--r-- | script-beta/brave/work.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/script-beta/brave/work.lua b/script-beta/brave/work.lua index bee159d6..5ec8178f 100644 --- a/script-beta/brave/work.lua +++ b/script-beta/brave/work.lua @@ -3,15 +3,19 @@ local parser = require 'parser' local fs = require 'bee.filesystem' local furi = require 'file-uri' local util = require 'utility' +local thread = require 'bee.thread' brave.on('loadProto', function () local jsonrpc = require 'jsonrpc' while true do - local proto = jsonrpc.decode(io.read, log.error) + local proto, err = jsonrpc.decode(io.read, log.error) --log.debug('loaded proto', proto.method) - if proto then - brave.push('proto', proto) + if not proto then + brave.push('protoerror', err) + return end + brave.push('proto', proto) + thread.sleep(0.001) end end) |