mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-02-07 06:44:11 +00:00
Handle resolution errors at startup
This commit is contained in:
parent
3e1c61a4b0
commit
bc9bef6ec1
@ -75,6 +75,13 @@ impl LightClientConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(server: http::Uri, dangerous: bool) -> io::Result<(LightClientConfig, u64)> {
|
pub fn create(server: http::Uri, dangerous: bool) -> io::Result<(LightClientConfig, u64)> {
|
||||||
|
use std::net::ToSocketAddrs;
|
||||||
|
// Test for a connection first
|
||||||
|
format!("{}:{}", server.host().unwrap(), server.port_part().unwrap())
|
||||||
|
.to_socket_addrs()?
|
||||||
|
.next()
|
||||||
|
.ok_or(std::io::Error::new(ErrorKind::ConnectionRefused, "Couldn't resolve server!"))?;
|
||||||
|
|
||||||
// Do a getinfo first, before opening the wallet
|
// Do a getinfo first, before opening the wallet
|
||||||
let info = grpcconnector::get_info(server.clone(), dangerous)
|
let info = grpcconnector::get_info(server.clone(), dangerous)
|
||||||
.map_err(|e| std::io::Error::new(ErrorKind::ConnectionRefused, e))?;
|
.map_err(|e| std::io::Error::new(ErrorKind::ConnectionRefused, e))?;
|
||||||
|
Loading…
Reference in New Issue
Block a user