Re: [R] Automatic traceback

2008-01-16 Thread Michael Hoffman
Prof Brian Ripley wrote:

> On Wed, 16 Jan 2008, Michael Hoffman wrote:
>
>> I would like to have an automatic traceback printed on error. Is there
>> a way to do this?
>
> There is a compact traceback printed automatically in non-interactive use,
> and you can turn that on by the following options
>
>  'showWarnCalls', 'showErrorCalls': a logical. Should warning and
>   error messages show a summary of the call stack?  By default
>   error calls are shown in non-interactive sessions.

Thanks, that is very helpful. Is there a way to get something slightly
more verbose?
-- 
Michael Hoffman

__
R-help@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.


Re: [R] Automatic traceback

2008-01-16 Thread Prof Brian Ripley
On Wed, 16 Jan 2008, Michael Hoffman wrote:

> I would like to have an automatic traceback printed on error. Is there
> a way to do this?
>
> options(error=traceback) seems to print the previous error, not the
> current error. I'm guessing this is because the traceback is not set
> until the error handler is done running.

Yes.  .Traceback is written immediately before the jump to toplevel, to 
allow e.g. try() to recover from the problem.

>> options(error=traceback)
>> stop("1")
> Error: 1
> No traceback available
>> stop("2")
> Error: 2
> 1: stop("1")
>> stop("3")
> Error: 3
> 1: stop("2")
>
> I am using R version 2.6.0 (2007-10-03).
>
There is a compact traceback printed automatically in non-interactive use, 
and you can turn that on by the following options

  'showWarnCalls', 'showErrorCalls': a logical. Should warning and
   error messages show a summary of the call stack?  By default
   error calls are shown in non-interactive sessions.


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


[R] Automatic traceback

2008-01-16 Thread Michael Hoffman
I would like to have an automatic traceback printed on error. Is there
a way to do this?

options(error=traceback) seems to print the previous error, not the
current error. I'm guessing this is because the traceback is not set
until the error handler is done running.

> options(error=traceback)
> stop("1")
Error: 1
No traceback available
> stop("2")
Error: 2
1: stop("1")
> stop("3")
Error: 3
1: stop("2")

I am using R version 2.6.0 (2007-10-03).
-- 
Michael Hoffman

__
R-help@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.