diff options
author | Rainer M. Krug <R.M.Krug@gmail.com> | 2014-01-21 10:35:52 +0100 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2014-01-26 11:05:46 -0700 |
commit | eaa3a761dae7686c6f3cb67092933b5e79c5ff87 (patch) | |
tree | d963c7903e2a2c48d6fe732ef245e718c19db9b6 | |
parent | e0d14e6aa7675e1a37125cea8a68b2119aa40d7d (diff) | |
download | org-mode-eaa3a761dae7686c6f3cb67092933b5e79c5ff87.tar.gz |
Graphic: Catch errors and return error message
* lisp/ob-R.el (org-babel-expand-body:R): Added the opening of the
tryCatch() wrapper
* lisp/ob-R.el (org-babel-R-construct-graphics-device-call): Added
closing of the wrapper containing the error function.
Added tryCatch() wrapper around the execution of the source block so
that if an error occurs
- the R graphic device is closed even when an error occurs
- a graph containing the error message is created
- the error message is printed in the R session in the form
ERROR : the error message
TINYCHANGE
-rw-r--r-- | lisp/ob-R.el | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lisp/ob-R.el b/lisp/ob-R.el index c907d18..62aa7f2 100644 --- a/lisp/ob-R.el +++ b/lisp/ob-R.el @@ -112,7 +112,7 @@ this variable.") (list (org-babel-R-construct-graphics-device-call graphics-file params)) inside - (list "dev.off()")) + (list "},error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off()")) inside)) "\n"))) @@ -295,7 +295,7 @@ Each member of this list is a list with three members: (substring (symbol-name (car pair)) 1) (cdr pair)) "")) params "")) - (format "%s(%s=\"%s\"%s%s%s)" + (format "%s(%s=\"%s\"%s%s%s); tryCatch({" device filearg out-file args (if extra-args "," "") (or extra-args "")))) |