Skip to content

Commit b88fff8

Browse files
dfalbellionel-
andauthored
Prevent error when expression is invalid for obtaining a help handler (#990)
* Improve error handling in help topic parsing * trace! -> warn! Co-authored-by: Lionel Henry <[email protected]> --------- Co-authored-by: Lionel Henry <[email protected]>
1 parent d94c9e4 commit b88fff8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/ark/src/help/r_help.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,15 @@ impl RHelp {
279279
RObject::from(R_GlobalEnv)
280280
})();
281281

282-
let obj = harp::parse_eval0(topic.as_str(), env.sexp)?;
282+
let obj = match harp::parse_eval0(topic.as_str(), env.sexp) {
283+
Ok(obj) => obj,
284+
Err(err) => {
285+
// Could not parse/eval the topic; no custom handler.
286+
log::warn!("Could not parse/eval help topic expression '{}': {:?}", topic, err);
287+
return Ok(None);
288+
}
289+
};
290+
283291
let handler: Option<RObject> =
284292
ArkGenerics::HelpGetHandler.try_dispatch(obj.sexp, vec![])?;
285293

0 commit comments

Comments
 (0)