Skip to content

Commit 022c2a3

Browse files
committed
catch evaluation error from R
1 parent ff20d56 commit 022c2a3

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/crolog.cpp

+29-3
Original file line numberDiff line numberDiff line change
@@ -1917,13 +1917,25 @@ PREDICATE(r_eval_, 1)
19171917
{
19181918
Language id("identity") ;
19191919
id.push_back(Expr) ;
1920-
Res = id.eval() ;
1920+
Res = Rcpp_eval(id, Environment::global_env()) ;
19211921
}
1922+
1923+
catch(const Rcpp::eval_error& ex)
1924+
{
1925+
throw PlException(PlTerm_string(ex.what())) ;
1926+
}
1927+
1928+
catch(std::runtime_error& ex)
1929+
{
1930+
throw PlException(PlTerm_string(ex.what())) ;
1931+
}
1932+
19221933
catch(std::exception& ex)
19231934
{
19241935
throw PlException(PlTerm_string(ex.what())) ;
19251936
return false ;
19261937
}
1938+
19271939
catch(...)
19281940
{
19291941
throw PlException(PlTerm_string("unknown exception")) ;
@@ -1954,13 +1966,25 @@ PREDICATE(r_eval_, 2)
19541966
{
19551967
Language id("identity") ;
19561968
id.push_back(Expr) ;
1957-
Res = id.eval() ;
1969+
Res = Rcpp_eval(id, Environment::global_env()) ;
19581970
}
1971+
1972+
catch(const Rcpp::eval_error& ex)
1973+
{
1974+
throw PlException(PlTerm_string(ex.what())) ;
1975+
}
1976+
1977+
catch(std::runtime_error& ex)
1978+
{
1979+
throw PlException(PlTerm_string(ex.what())) ;
1980+
}
1981+
19591982
catch(std::exception& ex)
19601983
{
19611984
throw PlException(PlTerm_string(ex.what())) ;
19621985
return false ;
19631986
}
1987+
19641988
catch(...)
19651989
{
19661990
throw PlException(PlTerm_string("unknown exception")) ;
@@ -1975,14 +1999,16 @@ PREDICATE(r_eval_, 2)
19751999
return false ;
19762000
}
19772001
}
2002+
19782003
catch(std::exception& ex)
19792004
{
19802005
throw PlException(PlTerm_string(ex.what())) ;
19812006
return false ;
19822007
}
2008+
19832009
catch(...)
19842010
{
1985-
throw PlException(PlTerm_string("unknown exception")) ;
2011+
throw PlException(PlTerm_string("unknown exception1")) ;
19862012
return false ;
19872013
}
19882014

0 commit comments

Comments
 (0)