diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-04-21 22:42:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 15:42:48 +0200 |
commit | 633322a020b0253aeb8c6eaeeed17d8a8fb53229 (patch) | |
tree | 5541be92a378b5599c5a2363f6fdb3d7e58655c0 /runtime/lua/vim/lsp/rpc.lua | |
parent | 0c637898f991ff9b90e695065a0136dd9c37106a (diff) | |
download | rneovim-633322a020b0253aeb8c6eaeeed17d8a8fb53229.tar.gz rneovim-633322a020b0253aeb8c6eaeeed17d8a8fb53229.tar.bz2 rneovim-633322a020b0253aeb8c6eaeeed17d8a8fb53229.zip |
lsp: do not assert even if the code does not exist in ErrorCodes (#11981)
There is ErrorCodes in the LSP specification, but in ResponseError.code
it is not used and the actual type is number.
Some language servers response original error cods and this is valid spec.
So we shouldn't assert even if the code does not exist in ErrorCodes.
ref: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#responseMessage
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 74d73da31f..dad1dc11f1 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -140,14 +140,23 @@ local function format_rpc_error(err) validate { err = { err, 't' }; } - local code_name = assert(protocol.ErrorCodes[err.code], "err.code is invalid") - local message_parts = {"RPC", code_name} + + -- There is ErrorCodes in the LSP specification, + -- but in ResponseError.code it is not used and the actual type is number. + local code + if protocol.ErrorCodes[err.code] then + code = string.format("code_name = %s,", protocol.ErrorCodes[err.code]) + else + code = string.format("code_name = unknown, code = %s,", err.code) + end + + local message_parts = {"RPC[Error]", code} if err.message then - table.insert(message_parts, "message = ") + table.insert(message_parts, "message =") table.insert(message_parts, string.format("%q", err.message)) end if err.data then - table.insert(message_parts, "data = ") + table.insert(message_parts, "data =") table.insert(message_parts, vim.inspect(err.data)) end return table.concat(message_parts, ' ') |