fix(handlers): more specific error messages (#16772)

Specify which message, or request, was last received in case of an error
instead of the same generic message
This commit is contained in:
kylo252
2022-04-30 13:55:26 +02:00
committed by GitHub
parent c618b314c6
commit eecc6535eb

View File

@@ -27,7 +27,7 @@ local function progress_handler(_, result, ctx, _)
local client = vim.lsp.get_client_by_id(client_id) local client = vim.lsp.get_client_by_id(client_id)
local client_name = client and client.name or string.format("id=%d", client_id) local client_name = client and client.name or string.format("id=%d", client_id)
if not client then if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message") err_message("LSP[", client_name, "] client has shut down during progress update")
return vim.NIL return vim.NIL
end end
local val = result.value -- unspecified yet local val = result.value -- unspecified yet
@@ -70,7 +70,7 @@ M['window/workDoneProgress/create'] = function(_, result, ctx)
local token = result.token -- string or number local token = result.token -- string or number
local client_name = client and client.name or string.format("id=%d", client_id) local client_name = client and client.name or string.format("id=%d", client_id)
if not client then if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message") err_message("LSP[", client_name, "] client has shut down while creating progress report")
return vim.NIL return vim.NIL
end end
client.messages.progress[token] = {} client.messages.progress[token] = {}
@@ -132,7 +132,7 @@ M['workspace/configuration'] = function(_, result, ctx)
local client_id = ctx.client_id local client_id = ctx.client_id
local client = vim.lsp.get_client_by_id(client_id) local client = vim.lsp.get_client_by_id(client_id)
if not client then if not client then
err_message("LSP[id=", client_id, "] client has shut down after sending the message") err_message("LSP[", client_id, "] client has shut down after sending a workspace/configuration request")
return return
end end
if not result.items then if not result.items then
@@ -449,7 +449,7 @@ M['window/logMessage'] = function(_, result, ctx, _)
local client = vim.lsp.get_client_by_id(client_id) local client = vim.lsp.get_client_by_id(client_id)
local client_name = client and client.name or string.format("id=%d", client_id) local client_name = client and client.name or string.format("id=%d", client_id)
if not client then if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message") err_message("LSP[", client_name, "] client has shut down after sending ", message)
end end
if message_type == protocol.MessageType.Error then if message_type == protocol.MessageType.Error then
log.error(message) log.error(message)
@@ -471,7 +471,7 @@ M['window/showMessage'] = function(_, result, ctx, _)
local client = vim.lsp.get_client_by_id(client_id) local client = vim.lsp.get_client_by_id(client_id)
local client_name = client and client.name or string.format("id=%d", client_id) local client_name = client and client.name or string.format("id=%d", client_id)
if not client then if not client then
err_message("LSP[", client_name, "] client has shut down after sending the message") err_message("LSP[", client_name, "] client has shut down after sending ", message)
end end
if message_type == protocol.MessageType.Error then if message_type == protocol.MessageType.Error then
err_message("LSP[", client_name, "] ", message) err_message("LSP[", client_name, "] ", message)