Skip to content

Commit

Permalink
refactor: unify the error handling methods in the crypto package that…
Browse files Browse the repository at this point in the history
… are different from the project style (#13097)

Signed-off-by: ChengenH <[email protected]>
  • Loading branch information
ChengenH authored Dec 16, 2024
1 parent ac20eac commit a506e3e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cl/beacon/builder/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (b *builderClient) RegisterValidator(ctx context.Context, registers []*clty
return err
}
_, err = httpCall[json.RawMessage](ctx, b.httpClient, http.MethodPost, url, nil, bytes.NewBuffer(payload))
if err == ErrNoContent {
if errors.Is(err, ErrNoContent) {
// no content is ok
return nil
}
Expand Down Expand Up @@ -144,7 +144,7 @@ func (b *builderClient) GetStatus(ctx context.Context) error {
path := "/eth/v1/builder/status"
url := b.url.JoinPath(path).String()
_, err := httpCall[json.RawMessage](ctx, b.httpClient, http.MethodGet, url, nil, nil)
if err == ErrNoContent {
if errors.Is(err, ErrNoContent) {
// no content is ok, we just need to check if the server is up
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cl/beacon/handler/block_production.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (a *ApiHandler) GetEthV1ValidatorAttestationData(
*committeeIndex,
)

if err == attestation_producer.ErrHeadStateBehind {
if errors.Is(err, attestation_producer.ErrHeadStateBehind) {
return beaconhttp.NewEndpointError(
http.StatusServiceUnavailable,
synced_data.ErrNotSynced,
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/forkchoice/on_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (f *ForkChoiceStore) OnBlock(ctx context.Context, block *cltypes.SignedBeac
// Check if blob data is available
if block.Version() >= clparams.DenebVersion && checkDataAvaiability {
if err := f.isDataAvailable(ctx, block.Block.Slot, blockRoot, block.Block.Body.BlobKzgCommitments); err != nil {
if err == ErrEIP4844DataNotAvailable {
if errors.Is(err, ErrEIP4844DataNotAvailable) {
return err
}
return fmt.Errorf("OnBlock: data is not available for block %x: %v", libcommon.Hash(blockRoot), err)
Expand Down
2 changes: 1 addition & 1 deletion cl/phase1/network/services/block_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (b *blockService) ProcessMessage(ctx context.Context, _ *uint64, msg *cltyp
b.publishBlockGossipEvent(msg)
// the rest of the validation is done in the forkchoice store
if err := b.processAndStoreBlock(ctx, msg); err != nil {
if err == forkchoice.ErrEIP4844DataNotAvailable {
if errors.Is(err, forkchoice.ErrEIP4844DataNotAvailable) {
b.scheduleBlockForLaterProcessing(msg)
return ErrIgnore
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (sub *ClientSubscription) quitWithError(unsubscribeServer bool, err error)
sub.requestUnsubscribe()
}
if err != nil {
if err == ErrClientQuit {
if errors.Is(err, ErrClientQuit) {
err = nil // Adhere to subscription semantics.
}
sub.err <- err
Expand Down

0 comments on commit a506e3e

Please sign in to comment.