| 310 | } |
| 311 | |
| 312 | inline SEXP make_condition(const std::string& ex_msg, SEXP call, SEXP cppstack, SEXP classes){ |
| 313 | Rcpp::Shield<SEXP> res( Rf_allocVector( VECSXP, 3 ) ) ; |
| 314 | #ifndef RCPP_USING_UTF8_ERROR_STRING |
| 315 | SET_VECTOR_ELT( res, 0, Rf_mkString( ex_msg.c_str() ) ) ; |
| 316 | #else |
| 317 | Rcpp::Shield<SEXP> ex_msg_rstring( Rf_allocVector( STRSXP, 1 ) ) ; |
| 318 | SET_STRING_ELT( ex_msg_rstring, 0, Rf_mkCharLenCE( ex_msg.c_str(), ex_msg.size(), CE_UTF8 ) ); |
| 319 | SET_VECTOR_ELT( res, 0, ex_msg_rstring ) ; |
| 320 | #endif |
| 321 | SET_VECTOR_ELT( res, 1, call ) ; |
| 322 | SET_VECTOR_ELT( res, 2, cppstack ) ; |
| 323 | |
| 324 | Rcpp::Shield<SEXP> names( Rf_allocVector( STRSXP, 3 ) ); |
| 325 | SET_STRING_ELT( names, 0, Rf_mkChar( "message" ) ) ; |
| 326 | SET_STRING_ELT( names, 1, Rf_mkChar( "call" ) ) ; |
| 327 | SET_STRING_ELT( names, 2, Rf_mkChar( "cppstack" ) ) ; |
| 328 | Rf_setAttrib( res, R_NamesSymbol, names ) ; |
| 329 | Rf_setAttrib( res, R_ClassSymbol, classes ) ; |
| 330 | return res ; |
| 331 | } |
| 332 | |
| 333 | template <typename Exception> |
| 334 | inline SEXP exception_to_condition_template( const Exception& ex, bool include_call) { |
no test coverage detected