diff --git a/cmd/crates/stellar-config/src/lib.rs b/cmd/crates/stellar-config/src/lib.rs index 223d39e4cd..d575e5b936 100644 --- a/cmd/crates/stellar-config/src/lib.rs +++ b/cmd/crates/stellar-config/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(clippy::missing_errors_doc)] use std::path::PathBuf; use clap::{arg, command}; diff --git a/cmd/crates/stellar-config/src/network.rs b/cmd/crates/stellar-config/src/network.rs index 5030170673..0ace81ea68 100644 --- a/cmd/crates/stellar-config/src/network.rs +++ b/cmd/crates/stellar-config/src/network.rs @@ -29,6 +29,10 @@ pub enum Error { InproperResponse(String), #[error("Currently not supported on windows. Please visit:\n{0}")] WindowsNotSupported(String), + #[error("Missing Authority in URL {0}")] + MissingAuthority(String), + #[error("Missing Scheme in URL {0}")] + MissingScheme(String), } #[derive(Debug, clap::Args, Clone, Default)] @@ -108,8 +112,9 @@ impl Network { let rpc_uri = Uri::from_str(&self.rpc_url) .map_err(|_| Error::InvalidUrl(self.rpc_url.to_string()))?; if self.network_passphrase.as_str() == passphrase::LOCAL { - let auth = rpc_uri.authority().unwrap().clone(); - let scheme = rpc_uri.scheme_str().unwrap(); + let auth = rpc_uri.authority().ok_or_else(|| Error::MissingAuthority(self.rpc_url.clone()))?.clone(); + let scheme = rpc_uri.scheme_str().ok_or_else(|| Error::MissingScheme(self.rpc_url.clone()))?; + Ok(Uri::builder() .authority(auth) .scheme(scheme) @@ -158,6 +163,7 @@ impl Network { } impl Network { + #[must_use] pub fn futurenet() -> Self { Network { rpc_url: "https://rpc-futurenet.stellar.org:443".to_owned(),