瀏覽代碼

尝试使用String返回错误

skyfffire 2 年之前
父節點
當前提交
871685d325
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      internal/ethapi/api.go

+ 3 - 3
internal/ethapi/api.go

@@ -972,7 +972,7 @@ type BatchCallArgs struct {
 // CallResult is the result of one call.
 type CallResult struct {
 	Return hexutil.Bytes
-	Error  error
+	Error  string
 }
 
 // BlockChainAPI provides an API to access Ethereum blockchain data.
@@ -1031,14 +1031,14 @@ func (s *PublicBlockChainAPI) BatchCall(ctx context.Context, config BatchCallCon
 		result, err := doCall(ctx, s.b, call.CallArgs, state, header, timeout, gp, &blockContext)
 		if err != nil {
 			fmt.Fprintf(os.Stderr, "call execution reverted: %v\n\n", err)
-			results = append(results, CallResult{Return: nil, Error: err})
+			results = append(results, CallResult{Return: nil, Error: err.Error()})
 		} else {
 			// If the result contains a revert reason, try to unpack it.
 			if len(result.Revert()) > 0 {
 				result.Err = newRevertError(result)
 			}
 
-			results = append(results, CallResult{Return: result.Return(), Error: result.Err})
+			results = append(results, CallResult{Return: result.Return(), Error: result.Err.Error()})
 		}
 	}
 	return results, nil