Skip to content

Commit 2bc0419

Browse files
committed
fix(godpu): change call for error messages with no format required
Signed-off-by: Mark Sanders <marksanders194@gmail.com>
1 parent fe521cb commit 2bc0419

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

testing/mock-server/server/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"bytes"
1010
context2 "context"
1111
"encoding/json"
12+
"errors"
1213
"fmt"
1314
"io"
1415
"log"
@@ -314,7 +315,7 @@ func FindStub(service, method string, in, out interface{}) error {
314315

315316
if resp.StatusCode != http.StatusOK {
316317
body, _ := io.ReadAll(resp.Body)
317-
return fmt.Errorf("%s", string(body))
318+
return errors.New(string(body))
318319
}
319320

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

326327
if respRPC.Error != "" {
327-
return fmt.Errorf("%s", respRPC.Error)
328+
return errors.New(respRPC.Error)
328329
}
329330

330331
data, _ := json.Marshal(respRPC.Data)

testing/mock-server/stub/storage.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package stub
66

77
import (
88
"encoding/json"
9+
"errors"
910
"fmt"
1011
"log"
1112
"os"
@@ -104,7 +105,7 @@ func stubNotFoundError(stub *findStubPayload, closestMatches []closeMatch) error
104105
template += expectString
105106

106107
if len(closestMatches) == 0 {
107-
return fmt.Errorf("%s", template)
108+
return errors.New(template)
108109
}
109110

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

134-
return fmt.Errorf("%s", template)
135+
return errors.New(template)
135136
}
136137

137138
// we made our own simple ranking logic

0 commit comments

Comments
 (0)