Skip to content

Commit 9591605

Browse files
authored
Fix: Check nil with stderr in plenary Job (#456)
1 parent ad0f445 commit 9591605

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lua/gitlab/job.lua

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ M.run_job = function(endpoint, method, body, callback)
1717
-- This handler will handle all responses from the Go server. Anything with a successful
1818
-- status will call the callback (if it is supplied for the job). Otherwise, it will print out the
1919
-- success message or error message and details from the Go server.
20+
local stderr = {}
2021
Job:new({
2122
command = "curl",
2223
args = args,
@@ -55,13 +56,20 @@ M.run_job = function(endpoint, method, body, callback)
5556
end
5657
end, 0)
5758
end,
58-
on_stderr = function()
59-
vim.defer_fn(function()
60-
u.notify("Could not run command!", vim.log.levels.ERROR)
61-
end, 0)
59+
on_stderr = function(_, data)
60+
if data then
61+
table.insert(stderr, data)
62+
end
6263
end,
63-
on_exit = function(_, status)
64+
on_exit = function(code, status)
6465
vim.defer_fn(function()
66+
if #stderr ~= 0 then
67+
u.notify(
68+
string.format("Could not run command `%s %s`! Stderr was:", code.command, table.concat(code.args, " ")),
69+
vim.log.levels.ERROR
70+
)
71+
vim.notify(string.format("%s", table.concat(stderr, "\n")), vim.log.levels.ERROR)
72+
end
6573
if status ~= 0 then
6674
u.notify(string.format("Go server exited with non-zero code: %d", status), vim.log.levels.ERROR)
6775
end

0 commit comments

Comments
 (0)