Expunge error-chain (feat. tomaka) (#2662)

* Remove error_chain

* Expunge error-chain from rpc and service.

* Expunge from transaction pool.

* Expunge from node/cli

* Expunge from keystore.

* Remove some boilerplate.

* Fix remaining stuff.

* Improve on deprecation message.

* Fix issues.

* Fix trnsaction pool tests.

* Fix the rest.

* Fix borked merge.

* Update lock
This commit is contained in:
Tomasz Drwięga
2019-05-24 11:35:31 +02:00
committed by Gavin Wood
parent 69ffec5822
commit c162fc5ff1
68 changed files with 951 additions and 1158 deletions
+10 -15
View File
@@ -55,7 +55,6 @@ use params::{
pub use params::{NoCustom, CoreParams};
pub use traits::{GetLogFilter, AugmentClap};
use app_dirs::{AppInfo, AppDataType};
use error_chain::bail;
use log::info;
use lazy_static::lazy_static;
@@ -145,10 +144,6 @@ fn base_path(cli: &SharedParams, version: &VersionInfo) -> PathBuf {
)
}
fn input_err<T: Into<String>>(msg: T) -> error::Error {
error::ErrorKind::Input(msg.into()).into()
}
/// Check whether a node name is considered as valid
fn is_node_name_valid(_name: &str) -> Result<(), &str> {
let name = _name.to_string();
@@ -278,7 +273,7 @@ where
/// Create an error caused by an invalid node key argument.
fn invalid_node_key(e: impl std::fmt::Display) -> error::Error {
input_err(format!("Invalid node key: {}", e))
error::Error::Input(format!("Invalid node key: {}", e))
}
/// Parse a Secp256k1 secret key from a hex string into a `network::Secret`.
@@ -334,7 +329,7 @@ fn fill_network_configuration(
}
for addr in cli.listen_addr.iter() {
let addr = addr.parse().map_err(|_| "Invalid listen multiaddress")?;
let addr = addr.parse().ok().ok_or(error::Error::InvalidListenMultiaddress)?;
config.listen_addresses.push(addr);
}
@@ -392,14 +387,14 @@ where
};
match is_node_name_valid(&config.name) {
Ok(_) => (),
Err(msg) => bail!(
input_err(
Err(msg) => Err(
error::Error::Input(
format!("Invalid node name '{}'. Reason: {}. If unsure, use none.",
config.name,
msg
)
)
)
)?
}
let base_path = base_path(&cli.shared_params, version);
@@ -417,7 +412,7 @@ where
Some(ref s) if s == "archive" => PruningMode::ArchiveAll,
None => PruningMode::default(),
Some(s) => PruningMode::keep_blocks(
s.parse().map_err(|_| input_err("Invalid pruning mode specified"))?
s.parse().map_err(|_| error::Error::Input("Invalid pruning mode specified".to_string()))?
),
};
@@ -851,7 +846,7 @@ mod tests {
NodeKeyConfig::Ed25519(network::Secret::Input(ref ski))
if node_key_type == NodeKeyType::Ed25519 &&
&sk[..] == ski.as_ref() => Ok(()),
_ => Err(input_err("Unexpected node key config"))
_ => Err(error::Error::Input("Unexpected node key config".into()))
})
})
}
@@ -877,7 +872,7 @@ mod tests {
if node_key_type == NodeKeyType::Secp256k1 && f == &file => Ok(()),
NodeKeyConfig::Ed25519(network::Secret::File(ref f))
if node_key_type == NodeKeyType::Ed25519 && f == &file => Ok(()),
_ => Err(input_err("Unexpected node key config"))
_ => Err(error::Error::Input("Unexpected node key config".into()))
})
})
}
@@ -911,7 +906,7 @@ mod tests {
if typ == NodeKeyType::Secp256k1 => Ok(()),
NodeKeyConfig::Ed25519(network::Secret::New)
if typ == NodeKeyType::Ed25519 => Ok(()),
_ => Err(input_err("Unexpected node key config"))
_ => Err(error::Error::Input("Unexpected node key config".into()))
})
})
}
@@ -928,7 +923,7 @@ mod tests {
NodeKeyConfig::Ed25519(network::Secret::File(ref f))
if typ == NodeKeyType::Ed25519 &&
f == &dir.join(NODE_KEY_ED25519_FILE) => Ok(()),
_ => Err(input_err("Unexpected node key config"))
_ => Err(error::Error::Input("Unexpected node key config".into()))
})
})
}