I was able to avoid writing some code twice using this method, but I was wondering if this is considered good style or not.
// Set the config file path
let config_path = settings::return_config_path(chain).unwrap_or_else(|err| {
println!("Error: {}, falling back to working directory", err);
//If there is an error set it to the current working directory
settings::return_local_path(chain).unwrap_or_else(|err| {
println!("{}", err);
std::process::exit(1);
})
});
Thanks, works like a charm :). Just getting used to rust, so far loving it, in c++ I had tons of bugs, rust compiler is ace man. I hope the language takes off...
If this is directly in main(), then it's fine. If it's inside any other function, then use Result and the ? operator. Use anyhow if you need a universal error type for these.