Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
propagate call errors
Browse files Browse the repository at this point in the history
  • Loading branch information
keorn committed Oct 6, 2016
1 parent b1ab0d0 commit 1bfac8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions rpc/src/v1/helpers/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro_rules! rpc_unimplemented {
}

use std::fmt;
use ethcore::error::Error as EthcoreError;
use ethcore::error::{Error as EthcoreError, CallError};
use ethcore::account_provider::{Error as AccountError};
use fetch::FetchError;
use jsonrpc_core::{Error, ErrorCode, Value};
Expand Down Expand Up @@ -219,4 +219,10 @@ pub fn from_transaction_error(error: EthcoreError) -> Error {
}
}


pub fn from_call_error(error: CallError) -> Error {
match error {
CallError::StatePruned => state_pruned(),
CallError::Execution(e) => internal("Execution error {}: ", e),
CallError::TransactionNotFound => internal("{}, this should not be the case with eth_call, most likely a bug.", CallError::TransactionNotFound),
}
}
5 changes: 4 additions & 1 deletion rpc/src/v1/impls/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ impl<C, S: ?Sized, M, EM> Eth for EthClient<C, S, M, EM> where
num => take_weak!(self.client).call(&signed, num.into(), Default::default()),
};

Ok(r.map(|e| Bytes(e.output)).unwrap_or(Bytes::new(vec![])))
match r {
Ok(b) => Ok(Bytes(b.output)),
Err(e) => Err(errors::from_call_error(e)),
}
}

fn estimate_gas(&self, request: CallRequest, num: Trailing<BlockNumber>) -> Result<RpcU256, Error> {
Expand Down

0 comments on commit 1bfac8a

Please sign in to comment.