fix: revert removing on_error_callback
This commit is contained in:
@@ -4,7 +4,7 @@ local Job = require("plenary.job")
|
|||||||
local u = require("gitlab.utils")
|
local u = require("gitlab.utils")
|
||||||
local M = {}
|
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 state = require("gitlab.state")
|
||||||
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s", state.settings.port) .. endpoint }
|
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s", state.settings.port) .. endpoint }
|
||||||
|
|
||||||
@@ -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
|
-- 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
|
-- 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 = {}
|
local stderr = {}
|
||||||
Job:new({
|
Job:new({
|
||||||
command = "curl",
|
command = "curl",
|
||||||
@@ -53,6 +54,9 @@ M.run_job = function(endpoint, method, body, callback)
|
|||||||
-- Handle error case
|
-- Handle error case
|
||||||
local message = string.format("%s: %s", data.message, data.details)
|
local message = string.format("%s: %s", data.message, data.details)
|
||||||
u.notify(message, vim.log.levels.ERROR)
|
u.notify(message, vim.log.levels.ERROR)
|
||||||
|
if on_error_callback then
|
||||||
|
on_error_callback(data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end, 0)
|
end, 0)
|
||||||
end,
|
end,
|
||||||
|
|||||||
Reference in New Issue
Block a user