mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 12:25:51 +00:00
Improved file not found error message (#9931)
* Say where you looked for the file Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -58,8 +58,9 @@ impl<G: RuntimeGenesis> GenesisSource<G> {
|
|||||||
|
|
||||||
match self {
|
match self {
|
||||||
Self::File(path) => {
|
Self::File(path) => {
|
||||||
let file =
|
let file = File::open(path).map_err(|e| {
|
||||||
File::open(path).map_err(|e| format!("Error opening spec file: {}", e))?;
|
format!("Error opening spec file at `{}`: {}", path.display(), e)
|
||||||
|
})?;
|
||||||
let genesis: GenesisContainer<G> = json::from_reader(file)
|
let genesis: GenesisContainer<G> = json::from_reader(file)
|
||||||
.map_err(|e| format!("Error parsing spec file: {}", e))?;
|
.map_err(|e| format!("Error parsing spec file: {}", e))?;
|
||||||
Ok(genesis.genesis)
|
Ok(genesis.genesis)
|
||||||
@@ -284,7 +285,8 @@ impl<G, E: serde::de::DeserializeOwned> ChainSpec<G, E> {
|
|||||||
|
|
||||||
/// Parse json file into a `ChainSpec`
|
/// Parse json file into a `ChainSpec`
|
||||||
pub fn from_json_file(path: PathBuf) -> Result<Self, String> {
|
pub fn from_json_file(path: PathBuf) -> Result<Self, String> {
|
||||||
let file = File::open(&path).map_err(|e| format!("Error opening spec file: {}", e))?;
|
let file = File::open(&path)
|
||||||
|
.map_err(|e| format!("Error opening spec file `{}`: {}", path.display(), e))?;
|
||||||
let client_spec =
|
let client_spec =
|
||||||
json::from_reader(file).map_err(|e| format!("Error parsing spec file: {}", e))?;
|
json::from_reader(file).map_err(|e| format!("Error parsing spec file: {}", e))?;
|
||||||
Ok(ChainSpec { client_spec, genesis: GenesisSource::File(path) })
|
Ok(ChainSpec { client_spec, genesis: GenesisSource::File(path) })
|
||||||
|
|||||||
Reference in New Issue
Block a user