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

chore: use errors.New to replace fmt.Errorf with no parameters #5074

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions core/common/ccpackage/ccpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func ValidateCip(baseCip, otherCip *peer.SignedChaincodeDeploymentSpec) error {
}

if (baseCip.OwnerEndorsements == nil && otherCip.OwnerEndorsements != nil) || (baseCip.OwnerEndorsements != nil && otherCip.OwnerEndorsements == nil) {
return fmt.Errorf("endorsements should either be both nil or not nil")
return errors.New("endorsements should either be both nil or not nil")
}

bN := len(baseCip.OwnerEndorsements)
oN := len(otherCip.OwnerEndorsements)
if bN > 1 || oN > 1 {
return fmt.Errorf("expect utmost 1 endorsement from a owner")
return errors.New("expect utmost 1 endorsement from a owner")
}

if bN != oN {
Expand All @@ -79,11 +79,11 @@ func ValidateCip(baseCip, otherCip *peer.SignedChaincodeDeploymentSpec) error {

func createSignedCCDepSpec(cdsbytes []byte, instpolicybytes []byte, endorsements []*peer.Endorsement) (*common.Envelope, error) {
if cdsbytes == nil {
return nil, fmt.Errorf("nil chaincode deployment spec")
return nil, errors.New("nil chaincode deployment spec")
}

if instpolicybytes == nil {
return nil, fmt.Errorf("nil instantiation policy")
return nil, errors.New("nil instantiation policy")
}

// create SignedChaincodeDeploymentSpec...
Expand Down Expand Up @@ -160,11 +160,11 @@ func CreateSignedCCDepSpecForInstall(pack []*common.Envelope) (*common.Envelope,
// optionally endorses it
func OwnerCreateSignedCCDepSpec(cds *peer.ChaincodeDeploymentSpec, instPolicy *common.SignaturePolicyEnvelope, owner identity.SignerSerializer) (*common.Envelope, error) {
if cds == nil {
return nil, fmt.Errorf("invalid chaincode deployment spec")
return nil, errors.New("invalid chaincode deployment spec")
}

if instPolicy == nil {
return nil, fmt.Errorf("must provide an instantiation policy")
return nil, errors.New("must provide an instantiation policy")
}

cdsbytes := protoutil.MarshalOrPanic(cds)
Expand Down Expand Up @@ -202,7 +202,7 @@ func OwnerCreateSignedCCDepSpec(cds *peer.ChaincodeDeploymentSpec, instPolicy *c
// SignExistingPackage adds a signature to a signed package.
func SignExistingPackage(env *common.Envelope, owner identity.SignerSerializer) (*common.Envelope, error) {
if owner == nil {
return nil, fmt.Errorf("owner not provided")
return nil, errors.New("owner not provided")
}

ch, sdepspec, err := ExtractSignedCCDepSpec(env)
Expand All @@ -211,11 +211,11 @@ func SignExistingPackage(env *common.Envelope, owner identity.SignerSerializer)
}

if ch == nil {
return nil, fmt.Errorf("channel header not found in the envelope")
return nil, errors.New("channel header not found in the envelope")
}

if sdepspec == nil || sdepspec.ChaincodeDeploymentSpec == nil || sdepspec.InstantiationPolicy == nil || sdepspec.OwnerEndorsements == nil {
return nil, fmt.Errorf("invalid signed deployment spec")
return nil, errors.New("invalid signed deployment spec")
}

// serialize the signing identity
Expand Down