Skip to content

Commit

Permalink
bug: dont panic in from_discrete_str
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Nov 5, 2024
1 parent 08bfbf6 commit de1d438
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/execution/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{
interface::{CalcOutGradientFunc, RhsGradientFunc, SetInputsGradientFunc, U0GradientFunc},
module::CodegenModule,
};
use anyhow::Result;
use anyhow::{Result, anyhow};
use target_lexicon::Triple;
use uid::Id;

Expand Down Expand Up @@ -50,8 +50,7 @@ impl<M: CodegenModule> Compiler<M> {
let uid = Id::<u32>::new();
let name = format!("diffsl_{}", uid);
let model = parse_ds_string(code).unwrap();
let model = DiscreteModel::build(name.as_str(), &model)
.unwrap_or_else(|e| panic!("{}", e.as_error_message(code)));
let model = DiscreteModel::build(name.as_str(), &model).map_err(|e| anyhow!(e.as_error_message(code)))?;
Self::from_discrete_model(&model)
}

Expand Down

0 comments on commit de1d438

Please sign in to comment.