Switching to anyhow consolidates the error types used and allows for more descriptive debug info for users.
QTUCQZKQLNVZCBQQ2OYHI7Q25G4OOLTLCWNSIHWRQOZAYU4UXAXQC
LRZO4TXD77ELZZPVN4NRWIDE22BHY6R7STI6RVWOJBIRSNRZX5VQC
F2AETINJDMXEKYXV2F73DBBWZNDIS4IQWTM7XO225V3RYVCW3Y6QC
YKRSSHFQEP3O6HC7DOF22ATRMG6Y5SZZHKT6A34YGWFIXQDFGSIQC
fn main() -> Result<(), Box<dyn std::error::Error>> {
fn main() -> Result<(), anyhow::Error> {
pub fn sanity_check(config_line: &Vec<&str>) -> Result<(), &'static str> {
pub fn sanity_check(config_line: &Vec<&str>) -> Result<(), anyhow::Error> {
return Err("0");
anyhow::bail!("Invalid type.");
return Err("1");
anyhow::bail!("Path does not begin with the root!");
return Err("2");
anyhow::bail!("Invalid file mode!");
pub fn create() -> Result<(), std::io::Error> {
pub fn create() -> Result<(), anyhow::Error> {
Err(e) => return Err(e),
Err(e) => anyhow::bail!("ERROR: Config parsing failed with error {}!", e),
Err(e) => anyhow::bail!("Config parsing failed with error {}!", e),
println!( "Failed to create {:#?} with reason {}!",
println!(
"Failed to create {:#?} with reason {}!",
anyhow::bail!( "Failed to create {:#?} with error {}!",
anyhow::bail!(
"Failed to create {:#?} with error {}!",
println!("Mode: {}", &line.mode); return Err(e);
println!("Mode: {}", &line.mode);
return Err(e);
println!("Failed to create {:#?}!", &line.path.as_os_str()); return Err(e);
println!("Failed to create {:#?}!", &line.path.as_os_str());
anyhow::bail!("Failed to create {:#?} with error {}!", &line.path.as_os_str(), e);
println!("Failed to write to {:#?}!", &line.path.as_os_str()); return Err(e);
println!("Failed to write to {:#?}!", &line.path.as_os_str());
anyhow::bail!("Failed to write to {:#?} with error {}!", &line.path.as_os_str(), e);
println!( "Failed to create {:#?} with mode {} with error {}!",
"Failed to create {:#?} with mode {} with error {}!",
&line.mode,
return Err(e.into());
_ => eprintln!( "ERROR: File type \"{}\" is not implemented.", line.file_type ),
_ => eprintln!(
"ERROR: File type \"{}\" is not implemented.",
line.file_type
),
_ => anyhow::bail!("File type '{}' is not supported.", line.file_type),
anyhow = "1.0.99"
name = "anyhow"version = "1.0.99"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"[[package]]
name = "anyhow"
version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
[[package]]
"anyhow",