Use function argument in error message instead of return value (#11244)

* Do not use return value in error handling

* Revert changes to EpochFromString & SlotFromString

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Co-authored-by: Nishant Das <nishdas93@gmail.com>
This commit is contained in:
Justin Traglia
2022-08-18 09:01:24 -05:00
committed by GitHub
parent 4af7d8230a
commit a65c670f5e
2 changed files with 6 additions and 6 deletions

View File

@@ -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)

View File

@@ -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{