Skip to content

Commit 93f5e4f

Browse files
Add better error handling for missing function
1 parent b6eee3a commit 93f5e4f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/set_cost.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,12 @@ impl UserDefinedCommand for EnableCostsDeclarations {
141141
fn update(&self, egraph: &mut EGraph, args: &[Expr]) -> Result<(), Error> {
142142
let span = args[0].span();
143143
if let [GenericExpr::Lit(_, Literal::String(name))] = args {
144-
let function = egraph.get_function(name).unwrap();
144+
let function = egraph.get_function(name).ok_or_else(|| {
145+
Error::ParseError(ParseError(
146+
span.clone(),
147+
format!("Function not found: {name}"),
148+
))
149+
})?;
145150
let input_sorts: Vec<_> = function
146151
.schema()
147152
.input

0 commit comments

Comments
 (0)