Skip to content

Commit

Permalink
fix(godpu): change call for error messages with no format required
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Sanders <marksanders194@gmail.com>
  • Loading branch information
sandersms committed Jan 20, 2025
1 parent fe521cb commit 2bc0419
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions testing/mock-server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"bytes"
context2 "context"
"encoding/json"
"errors"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -314,7 +315,7 @@ func FindStub(service, method string, in, out interface{}) error {

if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("%s", string(body))
return errors.New(string(body))
}

respRPC := new(response)
Expand All @@ -324,7 +325,7 @@ func FindStub(service, method string, in, out interface{}) error {
}

if respRPC.Error != "" {
return fmt.Errorf("%s", respRPC.Error)
return errors.New(respRPC.Error)
}

data, _ := json.Marshal(respRPC.Data)
Expand Down
5 changes: 3 additions & 2 deletions testing/mock-server/stub/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package stub

import (
"encoding/json"
"errors"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -104,7 +105,7 @@ func stubNotFoundError(stub *findStubPayload, closestMatches []closeMatch) error
template += expectString

if len(closestMatches) == 0 {
return fmt.Errorf("%s", template)
return errors.New(template)
}

highestRank := struct {
Expand All @@ -131,7 +132,7 @@ func stubNotFoundError(stub *findStubPayload, closestMatches []closeMatch) error
closestMatchString := renderFieldAsString(closestMatch.expect)
template += fmt.Sprintf("\n\nClosest Match \n\n%s:%s", closestMatch.rule, closestMatchString)

return fmt.Errorf("%s", template)
return errors.New(template)
}

// we made our own simple ranking logic
Expand Down

0 comments on commit 2bc0419

Please sign in to comment.