Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of fmt.Errorf #4467

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions common/cauthdsl/cauthdsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ SPDX-License-Identifier: Apache-2.0
package cauthdsl

import (
"fmt"
"time"

cb "github.com/hyperledger/fabric-protos-go/common"
mb "github.com/hyperledger/fabric-protos-go/msp"
"github.com/hyperledger/fabric/common/flogging"
"github.com/hyperledger/fabric/msp"
"github.com/pkg/errors"
"go.uber.org/zap/zapcore"
)

Expand All @@ -23,7 +23,7 @@ var cauthdslLogger = flogging.MustGetLogger("cauthdsl")
// passing them to this function for evaluation
func compile(policy *cb.SignaturePolicy, identities []*mb.MSPPrincipal) (func([]msp.Identity, []bool) bool, error) {
if policy == nil {
return nil, fmt.Errorf("Empty policy element")
return nil, errors.Errorf("Empty policy element")
}

switch t := policy.Type.(type) {
Expand Down Expand Up @@ -60,7 +60,7 @@ func compile(policy *cb.SignaturePolicy, identities []*mb.MSPPrincipal) (func([]
}, nil
case *cb.SignaturePolicy_SignedBy:
if t.SignedBy < 0 || t.SignedBy >= int32(len(identities)) {
return nil, fmt.Errorf("identity index out of range, requested %v, but identities length is %d", t.SignedBy, len(identities))
return nil, errors.Errorf("identity index out of range, requested %v, but identities length is %d", t.SignedBy, len(identities))
}
signedByID := identities[t.SignedBy]
return func(signedData []msp.Identity, used []bool) bool {
Expand All @@ -87,6 +87,6 @@ func compile(policy *cb.SignaturePolicy, identities []*mb.MSPPrincipal) (func([]
return false
}, nil
default:
return nil, fmt.Errorf("Unknown type: %T:%v", t, t)
return nil, errors.Errorf("Unknown type: %T:%v", t, t)
}
}
3 changes: 1 addition & 2 deletions common/ledger/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package util

import (
"encoding/binary"
"fmt"

"github.com/golang/protobuf/proto"
"github.com/pkg/errors"
Expand All @@ -43,7 +42,7 @@ func EncodeOrderPreservingVarUint64(number uint64) []byte {
}
sizeBytes := proto.EncodeVarint(uint64(size))
if len(sizeBytes) > 1 {
panic(fmt.Errorf("[]sizeBytes should not be more than one byte because the max number it needs to hold is 8. size=%d", size))
panic(errors.Errorf("[]sizeBytes should not be more than one byte because the max number it needs to hold is 8. size=%d", size))
}
encodedBytes := make([]byte, size+1)
encodedBytes[0] = sizeBytes[0]
Expand Down