Skip to content

Commit

Permalink
fixup! job: Teeny bit better logging
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Mendez <mmendez@equinix.com>
  • Loading branch information
mmlb committed Apr 23, 2021
1 parent 38c8d46 commit 0b0614c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions job/hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ type ComponentsResponse struct {
func (j Job) AddHardware(w http.ResponseWriter, req *http.Request) {
b, err := readClose(req.Body)
if err != nil {
j.Error(errors.Wrap(err, "reading hardware component body"))
j.Logger.Error(errors.Wrap(err, "reading hardware component body"))
w.WriteHeader(http.StatusBadRequest)
return
}

var response ComponentsResponse

if err := json.Unmarshal(b, &response); err != nil {
j.Error(errors.Wrap(err, "parsing hardware component as json"))
j.Logger.Error(errors.Wrap(err, "parsing hardware component as json"))
w.WriteHeader(http.StatusBadRequest)
return
}

jsonBody, err := json.Marshal(response)
if err != nil {
j.Error(errors.Wrap(err, "marshalling componenents as json"))
j.Logger.Error(errors.Wrap(err, "marshalling componenents as json"))
w.WriteHeader(http.StatusBadRequest)
return
}

if _, err := client.PostHardwareComponent(j.hardware.HardwareID(), bytes.NewReader(jsonBody)); err != nil {
j.Error(errors.Wrap(err, "posting componenents"))
j.Logger.Error(errors.Wrap(err, "posting componenents"))
w.WriteHeader(http.StatusBadRequest)
return
}
Expand Down

0 comments on commit 0b0614c

Please sign in to comment.