From 24f2b9ef1cee4945736dc339b18c1eba1ef0d5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Sat, 31 Jul 2021 22:26:02 +0200 Subject: [PATCH] fix(lsp): Include client name in handler error messages (#15227) Makes it easier to tell with language server caused an error. --- runtime/lua/vim/lsp/handlers.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua index a77c88e2dc..b7f1ea0ab6 100644 --- a/runtime/lua/vim/lsp/handlers.lua +++ b/runtime/lua/vim/lsp/handlers.lua @@ -457,12 +457,14 @@ for k, fn in pairs(M) do }) if err then + local client = vim.lsp.get_client_by_id(client_id) + local client_name = client and client.name or string.format("client_id=%d", client_id) -- LSP spec: -- interface ResponseError: -- code: integer; -- message: string; -- data?: string | number | boolean | array | object | null; - return err_message(tostring(err.code) .. ': ' .. err.message) + return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) end return fn(err, method, params, client_id, bufnr, config)