chain_spec_generator/
error.rs1use crate::generation::json::error::Error as JsonError;
2use std::{ffi::OsString, process::ExitStatus, string::FromUtf8Error};
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6#[non_exhaustive]
7pub enum Error {
8 #[error(transparent)]
9 ArgNotConvertibleToUtf8(#[from] FromUtf8Error),
10 #[error("{}: {}", .1, .0)]
11 IoError(std::io::Error, String),
12 #[error("{:?}: {:?}", .1, .0)]
13 ShellError(ExitStatus, String),
14 #[error("{:?}", .0)]
15 FsExtra(String),
16 #[error("Error: expected chainspec template file at {:?}, but it isn't there.", .0)]
17 ChainSpecSourceFileMissing(std::path::PathBuf),
18 #[error("Error: unable to losslessly convert '{:?}' into a String", .0)]
19 OsStringIsNotValidString(OsString),
20 #[error(transparent)]
21 JsonError(#[from] JsonError),
22}
23
24impl From<fs_extra::error::Error> for Error {
25 fn from(err: fs_extra::error::Error) -> Self {
26 let msg = format!("{:?}", err);
27 Error::FsExtra(msg)
28 }
29}