From 01c9ea2f80e0f816c151d6f6a336ad35f10653ba Mon Sep 17 00:00:00 2001 From: an-altosian Date: Tue, 17 Dec 2024 22:56:49 +0000 Subject: [PATCH] improve addchemistry error handling --- src/simpleaf_commands/chemistry.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/simpleaf_commands/chemistry.rs b/src/simpleaf_commands/chemistry.rs index d47904d..4908455 100644 --- a/src/simpleaf_commands/chemistry.rs +++ b/src/simpleaf_commands/chemistry.rs @@ -1,6 +1,6 @@ use crate::utils::af_utils::*; -use anyhow::{bail, Context, Result}; +use anyhow::{anyhow, bail, Context, Result}; use std::io::{Seek, Write}; use std::path::PathBuf; use tracing::info; @@ -20,10 +20,14 @@ pub fn add_chemistry(af_home_path: PathBuf, add_chem_cmd: Commands) -> Result<() } => { // check geometry string, if no good then // propagate error. - extract_geometry(&geometry)?; + match extract_geometry(&geometry) { + Ok(_) => {} + Err(e) => { + Err(anyhow!("Could not parse the input string to --geometry. Please make sure it is valid and wrapped in quotes. The error message was: {}", e))?; + } + }; Version::parse(version.as_ref()).with_context(|| format!("could not parse version {}. Please follow https://semver.org/. A valid example is 0.1.0", version))?; - // init the custom chemistry struct let custom_chem = CustomChemistry { name: name.clone(),