Re: [R] determining a parent function name

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Thu, 31 May 2007 07:51:32 -0700

Hi sundar --

maybe

> myerr <- function(err) err$call
> foo <- function() stop()
> tryCatch({ foo() }, error=myerr)

foo()

suggests a way to catch errors without having to change existing code or re-invent stop?

Martin

Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com> writes:

> Hi, Vladimir,
>
> Sorry, didn't see this reply. .Traceback <- NULL doesn't work because of
> the warning in ?traceback.
>
> Warning:
>
> It is undocumented where '.Traceback' is stored nor that it is
> visible, and this is subject to change. Prior to R 2.4.0 it was
> stored in the workspace, but no longer.
>
> Thanks,
>
> --sundar
>
> Vladimir Eremeev said the following on 5/31/2007 5:10 AM:
>>
>>
>> Vladimir Eremeev wrote:
>>> Does
>>> tail(capture.output(traceback()),n=1)
>>> do what you want?
>>>
>>> that is
>>>
>>
>> Hmmm... Seems, no...
>>
>> Having the earlier error() definition and
>>
>> bar<-function() error("asdasdf")
>> ft<-function() bar()
>>
>>
>>
>>> ft()
>>
>> I get in the tcl/tk window:
>>
>> Error in bar(): asdasdf
>>
>>> bar()
>>
>> I get in the tcl/tk window:
>>
>> Error in ft(): asdasdf
>>
>>> I get in the tcl/tk window:
>>
>> Error in bar(): asdasdf
>>
>> Some kind of the stack flushing is needed.
>> .Traceback<-NULL did not help
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

______________________________________________
R-help_at_stat.math.ethz.ch 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.
Received on Thu 31 May 2007 - 15:13:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 May 2007 - 20:33:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.