fix: handle parse errors

This commit is contained in:
Dimitri
2025-02-03 16:08:57 +07:00
parent b5fff4ed8d
commit 32426a8374

View File

@@ -19,8 +19,13 @@ pub fn genFromDecomposed(
) -> Result<String, JsValue> {
let mut decomposed_regex_config: DecomposedRegexConfig =
serde_json::from_str(decomposedRegexJson).expect("failed to parse decomposed_regex json");
let regex_and_dfa = get_regex_and_dfa(&mut decomposed_regex_config)
.expect("failed to convert the decomposed regex to dfa");
let regex_and_dfa = get_regex_and_dfa(&mut decomposed_regex_config).map_err(|e| {
JsValue::from_str(&format!(
"failed to convert the decomposed regex to dfa: {}",
e
))
})?;
gen_circom_string(&regex_and_dfa, circomTemplateName)
.map_err(|e| JsValue::from_str(&format!("Failed to generate Circom string: {}", e)))
}