Skip to content

Commit 0ba735d

Browse files
committed
catch exceptions from R
1 parent ed7f074 commit 0ba735d

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/crolog.cpp

+14-18
Original file line numberDiff line numberDiff line change
@@ -1922,18 +1922,16 @@ PREDICATE(r_eval_, 1)
19221922

19231923
catch(const Rcpp::eval_error& ex)
19241924
{
1925-
throw PlException(PlTerm_string(ex.what())) ;
1925+
PlCompound syntax("evaluation_error", PlTermv(A1)) ;
1926+
PlCompound context("context", PlTermv(PlTerm_string("foreign r_eval_/2"), PlTerm_string(ex.what()))) ;
1927+
throw PlException(PlCompound("error", PlTermv(syntax, context))) ;
19261928
}
19271929

1928-
catch(std::runtime_error& ex)
1929-
{
1930-
throw PlException(PlTerm_string(ex.what())) ;
1931-
}
1932-
1933-
catch(std::exception& ex)
1930+
catch(const std::exception& ex)
19341931
{
1935-
throw PlException(PlTerm_string(ex.what())) ;
1936-
return false ;
1932+
PlCompound syntax("evaluation_error", PlTermv(A1)) ;
1933+
PlCompound context("context", PlTermv(PlTerm_string("foreign r_eval_/2"), PlTerm_string(ex.what()))) ;
1934+
throw PlException(PlCompound("error", PlTermv(syntax, context))) ;
19371935
}
19381936

19391937
catch(...)
@@ -1971,18 +1969,16 @@ PREDICATE(r_eval_, 2)
19711969

19721970
catch(const Rcpp::eval_error& ex)
19731971
{
1974-
throw PlException(PlTerm_string(ex.what())) ;
1975-
}
1976-
1977-
catch(std::runtime_error& ex)
1978-
{
1979-
throw PlException(PlTerm_string(ex.what())) ;
1972+
PlCompound syntax("evaluation_error", PlTermv(A1)) ;
1973+
PlCompound context("context", PlTermv(PlTerm_string("foreign r_eval_/2"), PlTerm_string(ex.what()))) ;
1974+
throw PlException(PlCompound("error", PlTermv(syntax, context))) ;
19801975
}
19811976

1982-
catch(std::exception& ex)
1977+
catch(const std::exception& ex)
19831978
{
1984-
throw PlException(PlTerm_string(ex.what())) ;
1985-
return false ;
1979+
PlCompound syntax("evaluation_error", PlTermv(A1)) ;
1980+
PlCompound context("context", PlTermv(PlTerm_string("foreign r_eval_/2"), PlTerm_string(ex.what()))) ;
1981+
throw PlException(PlCompound("error", PlTermv(syntax, context))) ;
19861982
}
19871983

19881984
catch(...)

0 commit comments

Comments
 (0)