[R] ow to have R automatically print traceback upon errors

jim holtman jholtman at gmail.com
Tue Nov 24 05:00:12 CET 2009


I use this:

options(error=utils::recover)

and anytime an error occurs in the interactive mode, it will print out
the traceback and then allow you to explore the variables at each
level of the stack; just like putting 'browser()' in the code at the
error point.

Here is what I get in running under Windows:

> x <- function() xyz()  # non-existent function
>
>
> x()  # caa the function
Error in x() : could not find function "xyz"  <== error message

Enter a frame number, or 0 to exit

1: x()     <== traceback

Selection: 0
>


On Mon, Nov 23, 2009 at 7:52 PM, Hao Cen <hcen at andrew.cmu.edu> wrote:
> Hi,
>
> I wonder how to have R automatically print stack trace produced by
> traceback upon errors during interactive uses. I tried the suggestions on
> http://old.nabble.com/Automatically-execute-traceback-when-execution-of-script-causes-error--td22368483.html#a22368775
>
> and used options(error = recover)
> options(showErrorCalls = T)
>
> It just produces an extra message like "recover called non-interactively;
> frames dumped, use debugger() to view"
>
> Thanks
>
> Jeff
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list