mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Add defer recovery for failed txs when tracing
This commit is contained in:
parent
ad2a4cefac
commit
269b0fbc7a
1 changed files with 14 additions and 5 deletions
|
|
@ -611,12 +611,21 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
|||
TxIndex: i,
|
||||
TxHash: tx.Hash(),
|
||||
}
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Error: fmt.Sprintf("panic: %v", r)}
|
||||
}
|
||||
}()
|
||||
|
||||
res, err := api.traceTx(ctx, tx, msg, txctx, blockCtx, statedb, config)
|
||||
if err != nil {
|
||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
|
||||
} else {
|
||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
|
||||
return
|
||||
}
|
||||
results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
|
||||
}()
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue