mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added response body into error messages
This commit is contained in:
parent
00aaf1bf4c
commit
989ec611c6
1 changed files with 10 additions and 2 deletions
|
|
@ -40,8 +40,12 @@ func (c SmdClient) Add(data HTTPBody, headers HTTPHeader) error {
|
||||||
if res != nil {
|
if res != nil {
|
||||||
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
||||||
if !statusOk {
|
if !statusOk {
|
||||||
|
if len(body) > 0 {
|
||||||
|
return fmt.Errorf("%d: %s", res.StatusCode, string(body))
|
||||||
|
} else {
|
||||||
return fmt.Errorf("returned status code %d when adding endpoint", res.StatusCode)
|
return fmt.Errorf("returned status code %d when adding endpoint", res.StatusCode)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
@ -57,8 +61,12 @@ func (c SmdClient) Update(data HTTPBody, headers HTTPHeader) error {
|
||||||
if res != nil {
|
if res != nil {
|
||||||
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
statusOk := res.StatusCode >= 200 && res.StatusCode < 300
|
||||||
if !statusOk {
|
if !statusOk {
|
||||||
|
if len(body) > 0 {
|
||||||
|
return fmt.Errorf("%d: %s", res.StatusCode, string(body))
|
||||||
|
} else {
|
||||||
return fmt.Errorf("failed to update redfish endpoint (returned %s)", res.Status)
|
return fmt.Errorf("failed to update redfish endpoint (returned %s)", res.Status)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
fmt.Printf("%v (%v)\n%s\n", url, res.Status, string(body))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue