Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lua/gitlab/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local Job = require("plenary.job")
local u = require("gitlab.utils")
local M = {}

M.run_job = function(endpoint, method, body, callback)
M.run_job = function(endpoint, method, body, callback, on_error_callback)
local state = require("gitlab.state")
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s", state.settings.port) .. endpoint }

Expand All @@ -16,7 +16,8 @@ M.run_job = function(endpoint, method, body, callback)

-- This handler will handle all responses from the Go server. Anything with a successful
-- status will call the callback (if it is supplied for the job). Otherwise, it will print out the
-- success message or error message and details from the Go server.
-- success message or error message and details from the Go server and run the on_error_callback
-- (if supplied for the job).
local stderr = {}
Job:new({
command = "curl",
Expand Down Expand Up @@ -53,6 +54,9 @@ M.run_job = function(endpoint, method, body, callback)
-- Handle error case
local message = string.format("%s: %s", data.message, data.details)
u.notify(message, vim.log.levels.ERROR)
if on_error_callback then
on_error_callback(data)
end
end
end, 0)
end,
Expand Down
Loading