sketch.cut: refuse non-object params instead of panicking

This commit is contained in:
bherbruck authored and GitHub committed 2026-10-15 19:12:55 -04:00
1 parent 96d1ad0ab2
commit 4097ac0131
1 file changed
+5 -1
+5 -1
View File
@@ -209,8 +209,12 @@ fn copy(s: &mut Session, p: &Value) -> Result<Value> {
}
fn cut(s: &mut Session, p: &Value) -> Result<Value> {
// `q["entities"] = …` below panics on anything but an object.
if !(p.is_object() || p.is_null()) {
return Err(bad("sketch.cut", "params must be an object"));
}
let entities = chosen(s, p);
let mut q = p.clone();
let mut q = if p.is_null() { json!({}) } else { p.clone() };
q["entities"] = json!(entities);
let out = copy(s, &q)?;
let delete = super::find_command("sketch.delete").ok_or_else(|| bad("sketch.cut", "sketch.delete is missing"))?;