mirror of
https://github.com/kairos-io/tpm-helpers.git
synced 2025-08-08 01:03:53 +00:00
Include more info in the error msg on Dial() error
Include the HTTP Status CODE: it could help in diagnosing the connection failure. Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
This commit is contained in:
parent
a02dabe8fe
commit
30058b554b
6
get.go
6
get.go
@ -68,11 +68,15 @@ func Get(url string, opts ...Option) ([]byte, error) {
|
|||||||
logrus.Infof("Using TPMHash %s to dial %s", hash, wsURL)
|
logrus.Infof("Using TPMHash %s to dial %s", hash, wsURL)
|
||||||
conn, resp, err := dialer.Dial(wsURL, header)
|
conn, resp, err := dialer.Dial(wsURL, header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusUnauthorized {
|
if resp != nil {
|
||||||
|
if resp.StatusCode == http.StatusUnauthorized {
|
||||||
data, err := ioutil.ReadAll(resp.Body)
|
data, err := ioutil.ReadAll(resp.Body)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil, errors.New(string(data))
|
return nil, errors.New(string(data))
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("%w (Status: %s)", err, resp.Status)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user