From 22fef7fc0142ee505961b39af68165f86e08f290 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 3 Sep 2021 15:05:20 +0200 Subject: [PATCH] Return the error message from gvproxy When gvproxy returns an error we should add the body to the error message. For example this will now look like this: `something went wrong with the request: "listen tcp 0.0.0.0:8080: bind: address already in use\n` Signed-off-by: Paul Holzinger --- plugins/meta/podman-machine/restful.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/meta/podman-machine/restful.go b/plugins/meta/podman-machine/restful.go index 58dbe2d..e34de24 100644 --- a/plugins/meta/podman-machine/restful.go +++ b/plugins/meta/podman-machine/restful.go @@ -5,7 +5,9 @@ import ( "context" "encoding/json" "errors" + "fmt" "io" + "io/ioutil" "net" "net/http" "net/url" @@ -50,7 +52,11 @@ func postRequest(ctx context.Context, url *url.URL, body interface{}) error { return err } if resp.StatusCode != http.StatusOK { - return errors.New("something went wrong with the request") + b, err := ioutil.ReadAll(resp.Body) + if err == nil && len(b) > 0 { + return fmt.Errorf("something went wrong with the request: %q", string(b)) + } + return errors.New("something went wrong with the request, could not read response") } return nil }