branch: externals/ess commit 9b5f8000263c98960ff63c454f32d89c536d29e7 Author: Lionel Henry <lionel....@gmail.com> Commit: Lionel Henry <lionel....@gmail.com>
Propagate `ess-command` errors to elisp side --- doc/newfeat.texi | 2 ++ etc/ESSR.rds | Bin 15250 -> 79396 bytes etc/ESSR/R/.basic.R | 15 ++++++++++++--- test/ess-test-r.el | 6 ++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/newfeat.texi b/doc/newfeat.texi index e483d01d40..4ee3961aad 100644 --- a/doc/newfeat.texi +++ b/doc/newfeat.texi @@ -4,6 +4,8 @@ Changes and New Features in 19.04 (unreleased): @itemize @bullet +@item ESS[R]: Background commands now propagate errors to Emacs. + @item ESS[R]: Background commands can now be disabled by process instad of globally. For instance when a process has failed to initialize properly, background evals are disabled for that particular process to avoid diff --git a/etc/ESSR.rds b/etc/ESSR.rds index b4c4839f88..5203244f23 100644 Binary files a/etc/ESSR.rds and b/etc/ESSR.rds differ diff --git a/etc/ESSR/R/.basic.R b/etc/ESSR/R/.basic.R index 6eaca404e0..b7a41a57e6 100644 --- a/etc/ESSR/R/.basic.R +++ b/etc/ESSR/R/.basic.R @@ -235,9 +235,18 @@ if(.ess.Rversion < "1.8") invokeRestart("browser") } - out <- withCallingHandlers( - interrupt = restart, - withVisible(expr) + ## Should be an exiting handler to be able to catch + ## stack overflow errors + rethrow <- function(cnd) { + stop('ESSR::ERROR \"', conditionMessage(cnd), '\"') + } + + out <- tryCatch( + error = rethrow, + withCallingHandlers( + interrupt = restart, + withVisible(expr) + ) ) ## Print result manually because we can't rely on auto-print diff --git a/test/ess-test-r.el b/test/ess-test-r.el index 1efc94ec87..e138771347 100644 --- a/test/ess-test-r.el +++ b/test/ess-test-r.el @@ -922,6 +922,12 @@ https://github.com/emacs-ess/ESS/issues/725#issuecomment-431781558" (should (not (ess-can-eval-in-background)))))) (setenv "ESSR_TEST_LOAD_ERROR" nil))) +(etest-deftest ess-r-command-error-test () + (let ((err (should-error (ess-command "stop('bar')\n")))) + (should (string-match-p "R error during background ESS command ‘stop('bar')’\nError: bar" + (cadr err)))) + :inf-result "") + (provide 'ess-test-r)