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

Hao Cen hcen at andrew.cmu.edu
Thu Nov 26 16:46:42 CET 2009


Hi Jim,

Thanks for your suggestion. It is working now. The earlier message " recover
called non-interactively;
> frames dumped, use debugger() to view" happened within a R-IDE but doesn't
occur in a R console.

Jeff

-----Original Message-----
From: jim holtman [mailto:jholtman at gmail.com] 
Sent: Monday, November 23, 2009 11:00 PM
To: Hao Cen
Cc: r-help at r-project.org
Subject: Re: [R] ow to have R automatically print traceback upon errors

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-scri
pt-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