Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
eth: make tracing API errors more user friendly (#15589)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ruminer authored and fjl committed Dec 9, 2017
1 parent bbfe0b8 commit 732f546
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,12 @@ func (api *PrivateDebugAPI) traceBlock(block *types.Block, logConfig *vm.LogConf
}
statedb, err := blockchain.StateAt(blockchain.GetBlock(block.ParentHash(), block.NumberU64()-1).Root())
if err != nil {
return false, structLogger.StructLogs(), err
switch err.(type) {
case *trie.MissingNodeError:
return false, structLogger.StructLogs(), fmt.Errorf("required historical state unavailable")
default:
return false, structLogger.StructLogs(), err
}
}

receipts, _, usedGas, err := processor.Process(block, statedb, config)
Expand Down Expand Up @@ -518,7 +523,12 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, txHash common.
}
msg, context, statedb, err := api.computeTxEnv(blockHash, int(txIndex))
if err != nil {
return nil, err
switch err.(type) {
case *trie.MissingNodeError:
return nil, fmt.Errorf("required historical state unavailable")
default:
return nil, err
}
}

// Run the transaction with tracing enabled.
Expand Down

0 comments on commit 732f546

Please sign in to comment.