Skip to content

Commit 7a4fadc

Browse files
committed
forward empty error messages (#312)
1 parent 1114c95 commit 7a4fadc

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-06-25 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/Function.h: catch empty error messages
4+
* inst/include/Rcpp/api/meat/Rcpp_eval.h: protect call
5+
16
2015-06-18 Dirk Eddelbuettel <[email protected]>
27

38
* R/Attributes.R (evalCpp): Add support for plugings argument

inst/include/Rcpp/Function.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ namespace Rcpp{
7575
}
7676

7777
SEXP operator()() const {
78-
return Rcpp_eval( Rf_lang1( Storage::get__() ) ) ;
78+
Shield<SEXP> call(Rf_lang1(Storage::get__()));
79+
return Rcpp_eval(call);
7980
}
8081

8182
#include <Rcpp/generated/Function__operator.h>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace Rcpp{
2727
SEXP env;
2828
SEXP result;
2929
std::vector<std::string> warnings;
30+
bool error_occurred;
3031
std::string error_message;
3132
};
3233

@@ -80,8 +81,10 @@ namespace Rcpp{
8081
Shield<SEXP> current_error ( rcpp_get_current_error() ) ;
8182
Shield<SEXP> conditionMessageCall (::Rf_lang2(conditionMessageSym, current_error)) ;
8283
Shield<SEXP> condition_message (::Rf_eval(conditionMessageCall, R_GlobalEnv)) ;
84+
evalCall->error_occurred = true;
8385
evalCall->error_message = std::string(CHAR(::Rf_asChar(condition_message)));
8486
} else {
87+
evalCall->error_occurred = false;
8588
evalCall->result = res;
8689
}
8790
}
@@ -102,7 +105,7 @@ namespace Rcpp{
102105

103106
// handle error or result if it completed, else throw interrupt
104107
if (completed) {
105-
if (!call.error_message.empty())
108+
if (call.error_occurred)
106109
throw eval_error(call.error_message);
107110
else
108111
return call.result;

0 commit comments

Comments
 (0)