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

refactor: unify the error handling methods in the crypto package that are different from the project style #13097

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
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
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
Loading