From a65c670f5e4b08221e01e702cbd527684460c2e9 Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:01:24 -0500 Subject: [PATCH] Use function argument in error message instead of return value (#11244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Do not use return value in error handling * Revert changes to EpochFromString & SlotFromString Co-authored-by: Preston Van Loon Co-authored-by: Radosław Kapka Co-authored-by: Nishant Das --- cmd/helpers.go | 2 +- validator/slashing-protection-history/import.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/helpers.go b/cmd/helpers.go index 130390d2fd..1521fdcf65 100644 --- a/cmd/helpers.go +++ b/cmd/helpers.go @@ -88,7 +88,7 @@ func ExpandSingleEndpointIfFile(ctx *cli.Context, flag *cli.StringFlag) error { default: web3endpoint, err := file.ExpandPath(ctx.String(flag.Name)) if err != nil { - return errors.Wrapf(err, "could not expand path for %s", web3endpoint) + return errors.Wrapf(err, "could not expand path for %s", ctx.String(flag.Name)) } if err := ctx.Set(flag.Name, web3endpoint); err != nil { return errors.Wrapf(err, "could not set %s to %s", flag.Name, web3endpoint) diff --git a/validator/slashing-protection-history/import.go b/validator/slashing-protection-history/import.go index ebe2380ad8..024e74d3eb 100644 --- a/validator/slashing-protection-history/import.go +++ b/validator/slashing-protection-history/import.go @@ -316,14 +316,14 @@ func transformSignedBlocks(_ context.Context, signedBlocks []*format.SignedBlock for i, proposal := range signedBlocks { slot, err := SlotFromString(proposal.Slot) if err != nil { - return nil, fmt.Errorf("%d is not a valid slot: %w", slot, err) + return nil, fmt.Errorf("%s is not a valid slot: %w", proposal.Slot, err) } var signingRoot [32]byte // Signing roots are optional in the standard JSON file. if proposal.SigningRoot != "" { signingRoot, err = RootFromHex(proposal.SigningRoot) if err != nil { - return nil, fmt.Errorf("%#x is not a valid root: %w", signingRoot, err) + return nil, fmt.Errorf("%s is not a valid root: %w", proposal.SigningRoot, err) } } proposals[i] = kv.Proposal{ @@ -341,18 +341,18 @@ func transformSignedAttestations(pubKey [fieldparams.BLSPubkeyLength]byte, atts for _, attestation := range atts { target, err := EpochFromString(attestation.TargetEpoch) if err != nil { - return nil, fmt.Errorf("%d is not a valid epoch: %w", target, err) + return nil, fmt.Errorf("%s is not a valid epoch: %w", attestation.TargetEpoch, err) } source, err := EpochFromString(attestation.SourceEpoch) if err != nil { - return nil, fmt.Errorf("%d is not a valid epoch: %w", source, err) + return nil, fmt.Errorf("%s is not a valid epoch: %w", attestation.SourceEpoch, err) } var signingRoot [32]byte // Signing roots are optional in the standard JSON file. if attestation.SigningRoot != "" { signingRoot, err = RootFromHex(attestation.SigningRoot) if err != nil { - return nil, fmt.Errorf("%#x is not a valid root: %w", signingRoot, err) + return nil, fmt.Errorf("%s is not a valid root: %w", attestation.SigningRoot, err) } } historicalAtts = append(historicalAtts, &kv.AttestationRecord{