Skip to content

Commit

Permalink
Improve error reporting for help topic callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Sep 29, 2023
1 parent 1166301 commit f0d4458
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions crates/cmd-py/src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ impl HelpTopicRegistry {
breezy::help::HelpContents::Closure(Box::new(move |_| contents.clone()))
} else {
let f = contents.extract::<PyObject>(py)?;
let name = name.to_string();
breezy::help::HelpContents::Closure(Box::new(move |h| {
Python::with_gil(|py| {
let s = f.call1(py, (h,)).unwrap();
s.extract::<String>(py).unwrap()
Python::with_gil(|py| match f.call1(py, (h,)) {
Ok(s) => s.extract::<String>(py).unwrap(),
Err(e) => {
e.print(py);
panic!("error while generating help text for {}", name);
}
})
}))
};
Expand Down

0 comments on commit f0d4458

Please sign in to comment.