From 1bfac8ac0bb03637ad2a0998e50b5bce1fd79989 Mon Sep 17 00:00:00 2001
From: keorn <pczaban@gmail.com>
Date: Thu, 6 Oct 2016 15:57:07 +0100
Subject: [PATCH] propagate call errors

---
 rpc/src/v1/helpers/errors.rs | 10 ++++++++--
 rpc/src/v1/impls/eth.rs      |  5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/rpc/src/v1/helpers/errors.rs b/rpc/src/v1/helpers/errors.rs
index 885ec08f0b3..27695d14a07 100644
--- a/rpc/src/v1/helpers/errors.rs
+++ b/rpc/src/v1/helpers/errors.rs
@@ -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};
@@ -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),
+	}
+}
diff --git a/rpc/src/v1/impls/eth.rs b/rpc/src/v1/impls/eth.rs
index b174e406ef6..83ebe43424f 100644
--- a/rpc/src/v1/impls/eth.rs
+++ b/rpc/src/v1/impls/eth.rs
@@ -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> {