improve error handling

This commit is contained in:
Rossen Krastev 2023-12-30 00:30:53 +02:00 committed by GitHub
parent 09e0208029
commit c4bff96840
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -305,14 +305,15 @@ func (ec *Client) TransactionInBlock(ctx context.Context, blockHash common.Hash,
// TransactionReceipt returns the receipt of a transaction by transaction hash. // TransactionReceipt returns the receipt of a transaction by transaction hash.
// Note that the receipt is not available for pending transactions. // Note that the receipt is not available for pending transactions.
func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) { func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error) {
var r *types.Receipt var r *types.Receipt
err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash) err := ec.c.CallContext(ctx, &r, "eth_getTransactionReceipt", txHash)
if err == nil { if err != nil {
if r == nil { return nil, err
return nil, ethereum.NotFound }
} if r == nil {
} return nil, ethereum.NotFound
return r, err }
return r, nil
} }
// SyncProgress retrieves the current progress of the sync algorithm. If there's // SyncProgress retrieves the current progress of the sync algorithm. If there's