@@ -28,7 +28,7 @@ namespace Rcpp{
28
28
29
29
class exception : public std ::exception {
30
30
public:
31
- explicit exception (const char * message_) : message(message_){}
31
+ explicit exception (const char * message_) : message(message_){ rcpp_set_stack_trace ( stack_trace ()); }
32
32
exception (const char * message_, const char * file, int line ) : message(message_){
33
33
rcpp_set_stack_trace ( stack_trace (file,line) ) ;
34
34
}
@@ -127,17 +127,17 @@ namespace Rcpp{
127
127
} // namespace Rcpp
128
128
129
129
inline SEXP get_last_call (){
130
- SEXP sys_calls_symbol = Rf_install ( " sys.calls" ) ;
131
- Rcpp::Shield<SEXP> sys_calls_expr ( Rf_lang1 (sys_calls_symbol) );
130
+ SEXP sys_calls_symbol = Rf_install ( " sys.call" ) ;
131
+
132
+ // -9 Skips the wrapped tryCatch from Rcpp_eval
133
+ Rcpp::Shield<SEXP> sys_calls_expr ( Rf_lang2 (sys_calls_symbol, Rf_ScalarInteger (-9 )) );
132
134
Rcpp::Shield<SEXP> calls ( Rcpp_eval ( sys_calls_expr, R_GlobalEnv ) );
133
- SEXP res = calls ;
134
- while ( !Rf_isNull (CDR (res)) ) res = CDR (res);
135
- return CAR (res) ;
135
+ return calls;
136
136
}
137
137
138
138
inline SEXP get_exception_classes ( const std::string& ex_class) {
139
139
Rcpp::Shield<SEXP> res ( Rf_allocVector ( STRSXP, 4 ) );
140
-
140
+
141
141
#ifndef RCPP_USING_UTF8_ERROR_STRING
142
142
SET_STRING_ELT ( res, 0 , Rf_mkChar ( ex_class.c_str () ) ) ;
143
143
#else
@@ -184,7 +184,7 @@ inline SEXP exception_to_r_condition( const std::exception& ex){
184
184
185
185
inline SEXP string_to_try_error ( const std::string& str){
186
186
using namespace Rcpp ;
187
-
187
+
188
188
#ifndef RCPP_USING_UTF8_ERROR_STRING
189
189
Rcpp::Shield<SEXP> simpleErrorExpr ( Rf_lang2 (::Rf_install (" simpleError" ), Rf_mkString (str.c_str ())) );
190
190
Rcpp::Shield<SEXP> tryError ( Rf_mkString ( str.c_str () ) );
@@ -193,7 +193,7 @@ inline SEXP string_to_try_error( const std::string& str){
193
193
SET_STRING_ELT ( tryError, 0 , Rf_mkCharLenCE ( str.c_str (), str.size (), CE_UTF8 ) );
194
194
Rcpp::Shield<SEXP> simpleErrorExpr ( Rf_lang2 (::Rf_install (" simpleError" ), tryError ));
195
195
#endif
196
-
196
+
197
197
Rcpp::Shield<SEXP> simpleError ( Rf_eval (simpleErrorExpr, R_GlobalEnv) );
198
198
Rf_setAttrib ( tryError, R_ClassSymbol, Rf_mkString (" try-error" ) ) ;
199
199
Rf_setAttrib ( tryError, Rf_install ( " condition" ) , simpleError ) ;
@@ -267,52 +267,52 @@ namespace Rcpp{
267
267
inline void NORET stop (const std::string& message) {
268
268
throw Rcpp::exception (message.c_str ());
269
269
}
270
-
270
+
271
271
template <typename T1>
272
272
inline void NORET stop (const char * fmt, const T1& arg1) {
273
273
throw Rcpp::exception ( tfm::format (fmt, arg1 ).c_str () );
274
274
}
275
-
275
+
276
276
template <typename T1, typename T2>
277
277
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2) {
278
278
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2 ).c_str () );
279
279
}
280
-
280
+
281
281
template <typename T1, typename T2, typename T3>
282
282
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
283
283
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3).c_str () );
284
284
}
285
-
285
+
286
286
template <typename T1, typename T2, typename T3, typename T4>
287
287
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
288
288
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4).c_str () );
289
289
}
290
-
290
+
291
291
template <typename T1, typename T2, typename T3, typename T4, typename T5>
292
292
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
293
293
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5).c_str () );
294
294
}
295
-
295
+
296
296
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
297
297
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
298
298
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5, arg6).c_str () );
299
299
}
300
-
300
+
301
301
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
302
302
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) {
303
303
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7).c_str () );
304
304
}
305
-
305
+
306
306
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
307
307
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) {
308
308
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8).c_str () );
309
309
}
310
-
310
+
311
311
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
312
312
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) {
313
313
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9).c_str () );
314
314
}
315
-
315
+
316
316
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
317
317
inline void NORET stop (const char * fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) {
318
318
throw Rcpp::exception ( tfm::format (fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10).c_str () );
0 commit comments