Skip to content

ow to have R automatically print traceback upon errors

3 messages · jim holtman, Hao Cen

#
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
#
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:
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:

  
    
2 days later
#
Hi Jim,

Thanks for your suggestion. It is working now. The earlier message " recover
called non-interactively;
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:
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:
http://old.nabble.com/Automatically-execute-traceback-when-execution-of-scri
pt-causes-error--td22368483.html#a22368775
http://www.R-project.org/posting-guide.html