Skip to content

Commit

Permalink
Errors come back inside the JSON, these have to be handled as errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
oothman committed Feb 16, 2021
1 parent abe5fea commit 8cdfc7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions providers/hp/hp.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ type ChassisInfo struct {
BayNumber int
}
} `json:"Oem"`
Error struct {
Code string `json:"code"`
Message string `json:"message"`
ExtendedMessage []*struct {
MessageId string `json:"MessageId"`
} `json:"@Message.ExtendedInfo"`
} `json:"error"`
}

// Mem is the struct used to render the data from https://$ip/json/mem_info, it contains the ram data
Expand Down
7 changes: 7 additions & 0 deletions providers/hp/ilo/ilo.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ func (i *Ilo) parseChassisInfo() (*hp.ChassisInfo, error) {
if err != nil {
return nil, err
}
if chassisInfo.Error.Code != "" {
e := "Code: " + chassisInfo.Error.Code + ", Message: " + chassisInfo.Error.Message
for i, s := range chassisInfo.Error.ExtendedMessage {
e += fmt.Sprintf(", Extended[%d]: %s", i, s)
}
return nil, fmt.Errorf(e)
}

// Matching the new interface to the old one, since the code still drops
// off to the old interface in case the new interface is not available.
Expand Down

0 comments on commit 8cdfc7e

Please sign in to comment.