fix(lsp): Include client name in handler error messages (#15227)

Makes it easier to tell with language server caused an error.
This commit is contained in:
Mathias Fußenegger 2021-07-31 22:26:02 +02:00 committed by GitHub
parent 5f01714b25
commit 24f2b9ef1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)