Skip to content

Commit c9cbe55

Browse files
committed
refactor(getDiagnostics): remove pcall from logger import
1 parent 9bbb31d commit c9cbe55

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

lua/claudecode/tools/get_diagnostics.lua

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,17 @@ local function handler(params)
3232
})
3333
end
3434

35-
local log_module_ok, log = pcall(require, "claudecode.logger")
36-
if not log_module_ok then
37-
return {
38-
code = -32603, -- Internal error
39-
message = "Internal error",
40-
data = "Failed to load logger module",
41-
}
42-
end
35+
local logger = require("claudecode.logger")
4336

44-
log.debug("getDiagnostics handler called with params: " .. vim.inspect(params))
37+
logger.debug("getDiagnostics handler called with params: " .. vim.inspect(params))
4538

4639
-- Extract the uri parameter
4740
local diagnostics
4841

4942
if not params.uri then
5043
-- Get diagnostics for all buffers
51-
log.debug("Getting diagnostics for all open buffers")
5244
diagnostics = vim.diagnostic.get()
45+
logger.debug("Getting diagnostics for all open buffers")
5346
else
5447
-- Remove file:// prefix if present
5548
local uri = params.uri
@@ -62,15 +55,15 @@ local function handler(params)
6255
local bufnr = vim.fn.bufnr(filepath)
6356
if bufnr == -1 then
6457
-- File is not open in any buffer, throw an error
65-
log.debug("File buffer must be open to get diagnostics: " .. filepath)
58+
logger.debug("File buffer must be open to get diagnostics: " .. filepath)
6659
error({
6760
code = -32001,
6861
message = "File not open in buffer",
6962
data = "File must be open in Neovim to retrieve diagnostics: " .. filepath,
7063
})
7164
else
7265
-- Get diagnostics for the specific buffer
73-
log.debug("Getting diagnostics for bufnr: " .. bufnr)
66+
logger.debug("Getting diagnostics for bufnr: " .. bufnr)
7467
diagnostics = vim.diagnostic.get(bufnr)
7568
end
7669
end

0 commit comments

Comments
 (0)