Skip to content

Commit

Permalink
chore: use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored Jul 24, 2023
1 parent 962e935 commit 9032a81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions core/models/delay.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package models

import (
"errors"
"fmt"
"regexp"
"strings"
Expand Down Expand Up @@ -29,10 +28,10 @@ func ValidateResponseDelayPayload(j v1.ResponseDelayPayloadView) (err error) {
for _, delay := range j.Data {
if delay.UrlPattern != "" && delay.Delay != 0 {
if _, err := regexp.Compile(delay.UrlPattern); err != nil {
return errors.New(fmt.Sprintf("Response delay entry skipped due to invalid pattern : %s", delay.UrlPattern))
return fmt.Errorf("Response delay entry skipped due to invalid pattern : %s", delay.UrlPattern)
}
} else {
return errors.New(fmt.Sprintf("Config error - Missing values found in: %v", delay))
return fmt.Errorf("Config error - Missing values found in: %v", delay)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/models/delay_log_normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func ValidateResponseDelayLogNormalPayload(j v1.ResponseDelayLogNormalPayloadVie
}

if _, err := regexp.Compile(delay.UrlPattern); err != nil {
return errors.New(fmt.Sprintf("Response delay entry skipped due to invalid pattern : %s", delay.UrlPattern))
return fmt.Errorf("Response delay entry skipped due to invalid pattern : %s", delay.UrlPattern)
}

if err := coreDelay.ValidateLogNormalDelayOptions(delay.Min, delay.Max, delay.Mean, delay.Median); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion hoverctl/wrapper/hoverfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func Start(target *configuration.Target) error {
if err != nil {
log.Debug(err)
}
return errors.New(fmt.Sprintf("Timed out waiting for Hoverfly to become healthy, returns status: %v", statusCode))
return fmt.Errorf("Timed out waiting for Hoverfly to become healthy, returns status: %v", statusCode)
case <-tick:
resp, err := http.Get(fmt.Sprintf("http://localhost:%v/api/health", target.AdminPort))
if err == nil {
Expand Down

0 comments on commit 9032a81

Please sign in to comment.