More detailed fatal error reporting (#1016)

This commit is contained in:
Arkadiy Paronyan 2016-04-28 21:48:00 +02:00 committed by Gav Wood
parent 8f7624f5cb
commit f83a8f3ba1
4 changed files with 13 additions and 13 deletions

View File

@ -24,27 +24,27 @@ macro_rules! die {
($($arg:tt)*) => (die_with_message(&format!("{}", format_args!($($arg)*))));
}
pub fn die_with_error(e: ethcore::error::Error) -> ! {
pub fn die_with_error(module: &'static str, e: ethcore::error::Error) -> ! {
use ethcore::error::Error;
match e {
Error::Util(UtilError::StdIo(e)) => die_with_io_error(e),
_ => die!("{:?}", e),
Error::Util(UtilError::StdIo(e)) => die_with_io_error(module, e),
_ => die!("{}: {:?}", module, e),
}
}
pub fn die_with_io_error(e: std::io::Error) -> ! {
pub fn die_with_io_error(module: &'static str, e: std::io::Error) -> ! {
match e.kind() {
std::io::ErrorKind::PermissionDenied => {
die!("No permissions to bind to specified port.")
die!("{}: No permissions to bind to specified port.", module)
},
std::io::ErrorKind::AddrInUse => {
die!("Specified address is already in use. Please make sure that nothing is listening on the same port or try using a different one.")
die!("{}: Specified address is already in use. Please make sure that nothing is listening on the same port or try using a different one.", module)
},
std::io::ErrorKind::AddrNotAvailable => {
die!("Could not use specified interface or given address is invalid.")
die!("{}: Could not use specified interface or given address is invalid.", module)
},
_ => die!("{:?}", e),
_ => die!("{}: {:?}", module, e),
}
}

View File

@ -140,7 +140,7 @@ fn execute_client(conf: Configuration) {
// Build client
let mut service = ClientService::start(
client_config, spec, net_settings, &Path::new(&conf.path())
).unwrap_or_else(|e| die_with_error(e));
).unwrap_or_else(|e| die_with_error("Client", e));
panic_handler.forward_from(&service);
let client = service.client();

View File

@ -107,8 +107,8 @@ pub fn setup_rpc_server(
}
let start_result = server.start_http(url, cors_domain);
match start_result {
Err(RpcServerError::IoError(err)) => die_with_io_error(err),
Err(e) => die!("{:?}", e),
Err(RpcServerError::IoError(err)) => die_with_io_error("RPC", err),
Err(e) => die!("RPC: {:?}", e),
Ok(server) => {
server.set_panic_handler(move || {
deps.panic_handler.notify_all("Panic in RPC thread.".to_owned());

View File

@ -113,8 +113,8 @@ pub fn setup_webapp_server(
};
match start_result {
Err(webapp::ServerError::IoError(err)) => die_with_io_error(err),
Err(e) => die!("{:?}", e),
Err(webapp::ServerError::IoError(err)) => die_with_io_error("WebApps", err),
Err(e) => die!("WebApps: {:?}", e),
Ok(server) => {
server.set_panic_handler(move || {
deps.panic_handler.notify_all("Panic in WebApp thread.".to_owned());