Skip to content

Commit

Permalink
refactor: unify the error handling methods that are different from th…
Browse files Browse the repository at this point in the history
…e project style

Signed-off-by: LesCyber <andi4cing@gmail.com>
  • Loading branch information
LesCyber committed Mar 4, 2025
1 parent 6e44f42 commit 9465a61
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions x/feeds/types/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package types

import "fmt"
import "errors"

// AbsInt64 returns an absolute of int64.
// Panics on min int64 (-9223372036854775808).
Expand All @@ -15,7 +15,7 @@ func AbsInt64(x int64) int64 {
// StringToBytes32 converts a string to a fixed size byte array.
func StringToBytes32(str string) ([32]byte, error) {
if len(str) > 32 {
return [32]byte{}, fmt.Errorf("string is too long")
return [32]byte{}, errors.New("string is too long")
}

var byteArray [32]byte
Expand Down
4 changes: 2 additions & 2 deletions x/tss/testutil/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package testutil

import (
"fmt"
"errors"
"math/rand"
"time"

Expand Down Expand Up @@ -57,7 +57,7 @@ func GenerateSignature(
}

if member.MemberID == 0 {
return nil, fmt.Errorf("member not found")
return nil, errors.New("member not found")
}

// Compute own private nonce
Expand Down
3 changes: 2 additions & 1 deletion yoda/executor/multi.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package executor

import (
"errors"
"fmt"
"strings"
"sync/atomic"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (e *MultiExec) Exec(code []byte, arg string, env interface{}) (ExecResult,
errs := []error{}
for _, each := range e.nextExecOrder() {
res, err := each.Exec(code, arg, env)
if err == nil || err == ErrExecutionimeout {
if err == nil || errors.Is(err, ErrExecutionimeout) {
return res, err
} else {
errs = append(errs, err)
Expand Down

0 comments on commit 9465a61

Please sign in to comment.