Skip to content

Commit f0628c1

Browse files
authored
Satisfy new govet errors (#561)
1 parent fe9c17c commit f0628c1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

cmd/metal-api/internal/service/machine-service_allocation_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"bytes"
88
"context"
99
"encoding/json"
10+
"errors"
1011
"fmt"
1112
"log/slog"
1213
"net"
@@ -226,7 +227,7 @@ func allocMachine(container *restful.Container, ar v1.MachineAllocateRequest) (v
226227
resp := w.Result()
227228
defer resp.Body.Close()
228229
if resp.StatusCode != http.StatusOK {
229-
return v1.MachineResponse{}, fmt.Errorf(w.Body.String())
230+
return v1.MachineResponse{}, errors.New(w.Body.String())
230231
}
231232
var result v1.MachineResponse
232233
err = json.NewDecoder(resp.Body).Decode(&result)
@@ -248,7 +249,7 @@ func freeMachine(container *restful.Container, id string) (v1.MachineResponse, e
248249
resp := w.Result()
249250
defer resp.Body.Close()
250251
if resp.StatusCode != http.StatusOK {
251-
return v1.MachineResponse{}, fmt.Errorf(w.Body.String())
252+
return v1.MachineResponse{}, errors.New(w.Body.String())
252253
}
253254
var result v1.MachineResponse
254255
err = json.NewDecoder(resp.Body).Decode(&result)

cmd/metal-api/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ func run() error {
957957
restful.DefaultContainer.ServiceErrorHandler(func(serviceErr restful.ServiceError, request *restful.Request, response *restful.Response) {
958958
response.Header().Set("Content-Type", "application/json")
959959
response.WriteHeader(serviceErr.Code)
960-
err := response.WriteAsJson(httperrors.NewHTTPError(serviceErr.Code, fmt.Errorf(serviceErr.Message)))
960+
err := response.WriteAsJson(httperrors.NewHTTPError(serviceErr.Code, errors.New(serviceErr.Message)))
961961
if err != nil {
962962
logger.Error("Failed to send response", "error", err)
963963
return

0 commit comments

Comments
 (0)