Skip to content

Commit

Permalink
refactor:concat strings for error logs(#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamsouravjha committed Dec 26, 2023
1 parent ff9381c commit dc56629
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/hooks/settings/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ var (
func InitRealTimeOffset() error {
var monotonicTime, realTime unix.Timespec
if err := unix.ClockGettime(unix.CLOCK_MONOTONIC, &monotonicTime); err != nil {
return fmt.Errorf(Emoji, "failed getting monotonic clock due to: %v", err)
return fmt.Errorf("%s failed getting monotonic clock due to: %v", Emoji, err)
}
if err := unix.ClockGettime(unix.CLOCK_REALTIME, &realTime); err != nil {
return fmt.Errorf(Emoji, "failed getting real clock time due to: %v", err)
return fmt.Errorf("%s failed getting real clock time due to: %v", Emoji, err)
}
realTimeOffset = uint64(time.Second)*(uint64(realTime.Sec)-uint64(monotonicTime.Sec)) + uint64(realTime.Nsec) - uint64(monotonicTime.Nsec)
return nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/platform/yaml/testReport.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ func (fe *TestReport) Read(ctx context.Context, path, name string) (platform.Kin
var doc models.TestReport
err = decoder.Decode(&doc)
if err != nil {
return &models.TestReport{}, fmt.Errorf(Emoji, "failed to decode the yaml file documents. error: %v", err.Error())
return &models.TestReport{}, fmt.Errorf("%s failed to decode the yaml file documents. error: %v", Emoji, err.Error())
}
return &doc, nil
}

func (fe *TestReport) Write(ctx context.Context, path string, doc platform.KindSpecifier) error {
readDock, ok := doc.(*models.TestReport)
if !ok {
return fmt.Errorf(Emoji, "failed to read test report in yaml file.")
return fmt.Errorf("%s failed to read test report in yaml file.", Emoji)
}
if readDock.Name == "" {
lastIndex, err := findLastIndex(path, fe.Logger)
Expand All @@ -90,13 +90,13 @@ func (fe *TestReport) Write(ctx context.Context, path string, doc platform.KindS
data := []byte{}
d, err := yamlLib.Marshal(&doc)
if err != nil {
return fmt.Errorf(Emoji, "failed to marshal document to yaml. error: %s", err.Error())
return fmt.Errorf("%s failed to marshal document to yaml. error: %s", Emoji, err.Error())
}
data = append(data, d...)

err = os.WriteFile(filepath.Join(path, readDock.Name+".yaml"), data, os.ModePerm)
if err != nil {
return fmt.Errorf(Emoji, "failed to write test report in yaml file. error: %s", err.Error())
return fmt.Errorf("%s failed to write test report in yaml file. error: %s", Emoji, err.Error())
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/platform/yaml/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func hasBannedHeaders(object map[string]string, bannedHeaders []string) bool {
func (ys *Yaml) WriteTestcase(tcRead platform.KindSpecifier, ctx context.Context, filtersRead platform.KindSpecifier) error {
tc, ok := tcRead.(*models.TestCase)
if !ok {
return fmt.Errorf(Emoji, "failed to read testcase in WriteTestcase.")
return fmt.Errorf("%s failed to read testcase in WriteTestcase", Emoji)
}
filters, ok := filtersRead.(*models.Filters)

Expand Down

0 comments on commit dc56629

Please sign in to comment.