irongit

The dotfiles manager.

refactor: better error handling

huncholanehuncholaneauthored
parent 3b6f7b4commit 1ad23e36d4dbab7e80c9cdbf685b435171ebb0b9Browse files

1 file changed, +7 -4

+7-4src/main.rs
@@ -355,10 +355,13 @@ enum FlexEntry {
355355
356356 fn cmd_flex(args: FlexArgs) -> Result<()> {
357357 let url = args.url.as_deref().unwrap_or(DEFAULT_FLEX_URL);
358- let yaml = fetch_text(url).or_else(|_| {
359- // Fallback to local flex.yml if remote fails
360- fs::read_to_string("flex.yml").context("Failed to fetch and failed to read local flex.yml")
361- })?;
358+ let yaml = match fetch_text(url) {
359+ Ok(text) => text,
360+ Err(_) => {
361+ eprintln!("\x1b[31mFailed to fetch the flex file. Please enure you have internet connection.\x1b[0m");
362+ std::process::exit(1);
363+ }
364+ };
362365
363366 let map: HashMap<String, FlexEntry> = serde_yaml::from_str(&yaml)
364367 .context("Parsing YAML for flex")?;