Skip to content

Commit f3567f2

Browse files
committed
wrap in check for 'condition' class as well
1 parent 454de74 commit f3567f2

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

inst/include/Rcpp/api/meat/Rcpp_eval.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,25 @@ inline SEXP Rcpp_eval(SEXP expr, SEXP env) {
5656
// execute the call
5757
Shield<SEXP> res(::Rf_eval(call, R_GlobalEnv));
5858

59-
// check for error
60-
if (Rf_inherits(res, "error")) {
59+
// check for condition results (errors, interrupts)
60+
if (Rf_inherits(res, "condition")) {
6161

62-
Shield<SEXP> conditionMessageCall(::Rf_lang2(
63-
::Rf_install("conditionMessage"),
64-
res
65-
));
62+
if (Rf_inherits(res, "error")) {
63+
64+
Shield<SEXP> conditionMessageCall(::Rf_lang2(
65+
::Rf_install("conditionMessage"),
66+
res
67+
));
68+
69+
Shield<SEXP> conditionMessage(::Rf_eval(conditionMessageCall, R_GlobalEnv));
70+
throw eval_error(CHAR(STRING_ELT(conditionMessage, 0)));
71+
}
72+
73+
// check for interrupt
74+
if (Rf_inherits(res, "interrupt")) {
75+
throw internal::InterruptedException();
76+
}
6677

67-
Shield<SEXP> conditionMessage(::Rf_eval(conditionMessageCall, R_GlobalEnv));
68-
throw eval_error(CHAR(STRING_ELT(conditionMessage, 0)));
69-
}
70-
71-
// check for interrupt
72-
if (Rf_inherits(res, "interrupt")) {
73-
throw internal::InterruptedException();
7478
}
7579

7680
return res;

0 commit comments

Comments
 (0)