Port try macro to new ? operator. (#3962)

* initial untry sweep

* restore try in ipc codegen, fix inference

* change a few missed try instances
This commit is contained in:
Robert Habermeier
2016-12-27 12:53:56 +01:00
committed by Arkadiy Paronyan
parent b1ef52a6d7
commit 8125b5690c
165 changed files with 1696 additions and 1696 deletions

View File

@@ -114,16 +114,16 @@ impl<F: Fetch + 'static> HashFetch for Client<F> {
Ok(url) => {
let future = self.fetch.fetch(&url).then(move |result| {
fn validate_hash(path: PathBuf, hash: H256, result: Result<Response, FetchError>) -> Result<PathBuf, Error> {
let response = try!(result);
let response = result?;
// Read the response
let mut reader = io::BufReader::new(response);
let mut writer = io::BufWriter::new(try!(fs::File::create(&path)));
try!(io::copy(&mut reader, &mut writer));
try!(writer.flush());
let mut writer = io::BufWriter::new(fs::File::create(&path)?);
io::copy(&mut reader, &mut writer)?;
writer.flush()?;
// And validate the hash
let mut file_reader = io::BufReader::new(try!(fs::File::open(&path)));
let content_hash = try!(sha3(&mut file_reader));
let mut file_reader = io::BufReader::new(fs::File::open(&path)?);
let content_hash = sha3(&mut file_reader)?;
if content_hash != hash {
Err(Error::HashMismatch{ got: content_hash, expected: hash })
} else {

View File

@@ -119,12 +119,12 @@ impl URLHintContract {
fn urlhint_address(&self) -> Option<Address> {
let res = || {
let get_address = try!(self.registrar.function("getAddress".into()).map_err(as_string));
let params = try!(get_address.encode_call(
let get_address = self.registrar.function("getAddress".into()).map_err(as_string)?;
let params = get_address.encode_call(
vec![Token::FixedBytes((*"githubhint".sha3()).to_vec()), Token::String("A".into())]
).map_err(as_string));
let output = try!(self.client.call(try!(self.client.registrar()), params));
let result = try!(get_address.decode_output(output).map_err(as_string));
).map_err(as_string)?;
let output = self.client.call(self.client.registrar()?, params)?;
let result = get_address.decode_output(output).map_err(as_string)?;
match result.get(0) {
Some(&Token::Address(address)) if address != *Address::default() => Ok(address.into()),