[Rd] Tracebacks with tryCatch() and withCallingHandlers()?
Kurt Hornik
Kurt.Hornik at wu-wien.ac.at
Thu Sep 8 08:42:46 CEST 2005
>>>>> Henrik Bengtsson writes:
> When batch processing analysis, I use tryCatch() for failure handling
> and to prevent unwanted interrupts. I write detailed progress to log
> file and conditions (warnings and errors) are written to the same log
> file immediately by using withCallingHandlers(..., condition=function(c)
> cat(c, file=logFile)). However, I would also like to write the call
> stack to the log file to further simplify troubleshooting; traceback()
> does unfortunately not work here. From ?traceback, we have
> "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 the last error."
> (and it seems to be case for withCallingHandlers() too). Does anyone
> know of a workaround for this? Is there a way to get the call stack
> within the condition handler?
tools:::.try_quietly() tries doing something similar (catch errors and
print a traceback) [the code is not necessarily a thing of beauty ...].
Hth
Best
-k
More information about the R-devel
mailing list