From 38ee142041b70482301395d9751c8cc482332992 Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Fri, 19 Aug 2022 13:05:25 +0200 Subject: [PATCH] Return err when error occures --- proxmox/client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxmox/client.go b/proxmox/client.go index a504daf2..2dff5a78 100644 --- a/proxmox/client.go +++ b/proxmox/client.go @@ -1752,7 +1752,7 @@ func (c *Client) CreateItemWithTask(Params map[string]interface{}, url string) ( var resp *http.Response resp, err = c.session.Post(url, nil, nil, &reqbody) if err != nil { - return c.HandleTaskError(resp) + return c.HandleTaskError(resp), err } return c.CheckTask(resp) } @@ -1769,7 +1769,7 @@ func (c *Client) UpdateItemWithTask(Params map[string]interface{}, url string) ( var resp *http.Response resp, err = c.session.Put(url, nil, nil, &reqbody) if err != nil { - return c.HandleTaskError(resp) + return c.HandleTaskError(resp), err } return c.CheckTask(resp) } @@ -1784,7 +1784,7 @@ func (c *Client) DeleteUrlWithTask(url string) (exitStatus string, err error) { var resp *http.Response resp, err = c.session.Delete(url, nil, nil) if err != nil { - return c.HandleTaskError(resp) + return c.HandleTaskError(resp), err } return c.CheckTask(resp) } @@ -1795,7 +1795,7 @@ func (c *Client) GetItemList(url string) (list map[string]interface{}, err error } // Close task responce -func (c *Client) HandleTaskError(resp *http.Response) (exitStatus string, err error) { +func (c *Client) HandleTaskError(resp *http.Response) (exitStatus string) { defer resp.Body.Close() // This might not work if we never got a body. We'll ignore errors in trying to read, // but extract the body if possible to give any error information back in the exitStatus