[R] No traceback available when using try(...)
Edouard DUCHESNAY
duchesnay at shfj.cea.fr
Thu Mar 11 12:08:00 CET 2004
Hello,
1. The Situation :
------------------------
The stack traceback is not available when error ouccured in a try(....)
-- test.R --------------------------------
f<-function(a){
return ( log(a) )
}
try(f("A"))
traceback()
-------------------------------------------
I get the following message :
> try(f("A"))
Error in log(x) : Non-numeric argument to mathematical function
> traceback()
No traceback available
I try to use tryCatch(...) instead, I could get the stack traceback (using the finally),
but the R program stop.
2. My goal
--------------------
All I need is to prevent a error to stop a program (like try() does), print the traceback
just after the try(....), and get the error message (geterrmessage()).
3. Question
-------------------
A) stack traceback is not available when error ouccured in a try is a normal behavior ?
B) Do you have any sugestion to fill my goal ?
C) If not is it a good idea to investigate around withRestarts(expr, ...) ?
Best regards
PS : My R Version 1.8.1 (2003-11-21)
--
Edouard Duchesnay Tel: +33 1 69 86 78 52
CEA - SHFJ Fax: +33 1 69 86 77 86
4, place du Général Leclerc
91401 Orsay Cedex France
More information about the R-help
mailing list