Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Return the error message from gvproxy
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Luap99 committed Sep 3, 2021
1 parent 325c513 commit 22fef7f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/meta/podman-machine/restful.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -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
}

0 comments on commit 22fef7f

Please sign in to comment.