From luke at stat.uiowa.edu  Wed Sep  2 22:04:57 2009
From: luke at stat.uiowa.edu (luke at stat.uiowa.edu)
Date: Wed, 2 Sep 2009 15:04:57 -0500 (CDT)
Subject: [Rd] Tracebacks & try
In-Reply-To: <f8e6ff050909020608v3e59065bre2749c4e5822e636@mail.gmail.com>
References: <f8e6ff050909020608v3e59065bre2749c4e5822e636@mail.gmail.com>
Message-ID: <alpine.OSX.2.00.0909021504080.1230@luke-tierneys-macbook-pro-15.local>

You can use a calling handler along with sys.calls, something like

     f <- function() g()
     g <- function() stop("A")

     tryCatch(withCallingHandlers(f(),
 				 error = function(e) {
 						  e$calls <- sys.calls()
 				     signalCondition(e)
 				 }),
 	     error = function(e) e)

Best,

luke

On Wed, 2 Sep 2009, Hadley Wickham wrote:

> Hi all,
>
> The help for traceback states:
>
>  Errors which are caught _via_ 'try' or 'tryCatch' do not generate
>  a traceback, so what is printed is the call sequence for the last
>  uncaught error, and not necessarily for the last error.
>
> Is there any way to get a traceback (or something similar) for an
> error raised inside a try block?
>
> Regards,
>
> Hadley
>
>
>

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke at stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] Tracebacks & try
luke at stat.uiowa.edu