From c4bff9684063ef9d32ef374478559ae125d53408 Mon Sep 17 00:00:00 2001 From: Rossen Krastev Date: Sat, 30 Dec 2023 00:30:53 +0200 Subject: [PATCH] improve error handling --- ethclient/ethclient.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index e8a201f71b..7a1c42f96e 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -305,14 +305,15 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash, // TransactionReceipt returns the receipt of a transaction by transaction hash. // Note that the receipt is not available for pending transactions. func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { - var r *types.Receipt - err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash) - if err == nil { - if r == nil { - return nil, ethereum.NotFound - } - } - return r, err + var r *types.Receipt + err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash) + if err != nil { + return nil, err + } + if r == nil { + return nil, ethereum.NotFound + } + return r, nil } // SyncProgress retrieves the current progress of the sync algorithm. If there's