MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / string_to_try_error

Function string_to_try_error

inst/include/Rcpp/exceptions.h:366–384  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366inline SEXP string_to_try_error( const std::string& str){
367 using namespace Rcpp;
368
369 #ifndef RCPP_USING_UTF8_ERROR_STRING
370 Rcpp::Shield<SEXP> txt(Rf_mkString(str.c_str()));
371 Rcpp::Shield<SEXP> simpleErrorExpr(Rf_lang2(::Rf_install("simpleError"), txt));
372 Rcpp::Shield<SEXP> tryError( Rf_mkString( str.c_str() ) );
373 #else
374 Rcpp::Shield<SEXP> tryError( Rf_allocVector( STRSXP, 1 ) ) ;
375 SET_STRING_ELT( tryError, 0, Rf_mkCharLenCE( str.c_str(), str.size(), CE_UTF8 ) );
376 Rcpp::Shield<SEXP> simpleErrorExpr( Rf_lang2(::Rf_install("simpleError"), tryError ));
377 #endif
378
379 Rcpp::Shield<SEXP> simpleError( Rf_eval(simpleErrorExpr, R_GlobalEnv) );
380 Rf_setAttrib( tryError, R_ClassSymbol, Rf_mkString("try-error") ) ;
381 Rf_setAttrib( tryError, Rf_install( "condition") , simpleError ) ;
382
383 return tryError; // #nocov end
384}
385
386inline SEXP exception_to_try_error( const std::exception& ex){
387 return string_to_try_error(ex.what());

Callers 1

exception_to_try_errorFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected