From dmurdoch at pair.com  Fri Mar 12 21:39:28 2004
From: dmurdoch at pair.com (dmurdoch@pair.com)
Date: Fri Mar 12 21:39:33 2004
Subject: [Rd] Re: [R] No traceback available when using try(...) (PR#6669)
Message-ID: <20040312203928.75CBFFB88@slim.kubism.ku.dk>

On Fri, 12 Mar 2004 11:44:14 -0500, "Roger D. Peng" <rpeng@jhsph.edu>
wrote :

>Funny, it works for me on R-patched
>
> > f <- function(a) { return(log(a)) }
> > f("A")
>Error in log(x) : Non-numeric argument to mathematical function
> > traceback()
>2: log(a)
>1: f("A")
> > try(f("A"))
>Error in log(x) : Non-numeric argument to mathematical function
> > traceback()
>2: log(a)
>1: f("A")

Oops, I get the same behaviour as you now.  I think I must have edited
the transcript before and changed the order of the lines:  now I get
the "no traceback" message only if the try(f("A")) comes first.  And
notice this infelicity:

> f("A")
Error in log(x) : Non-numeric argument to mathematical function
> traceback()
2: log(a)
1: f("A")
> try(f("B"))
Error in log(x) : Non-numeric argument to mathematical function
> traceback()
2: log(a)
1: f("A")                  # The wrong traceback!

Presumably what is happening is that the second error leaves the old
traceback in place in both situations.  I don't think it should do
that.  Luke says the trace is unavailable by the time the try()
returns; could the old one be cleared at the time of the error, to
avoid giving misleading information?

Duncan Murdoch


[Rd] Re: [R] No traceback available when using try(...) (PR#6669)
dmurdoch@pair.com