tryCatch: go on executing after a warning message
1
0
Entering edit mode
@javier-perez-florido-3121
Last seen 6.1 years ago
Dear list, I have a code sample in which a single assignment is returned. What I want to do is to collect all warning messages found in the example (they are forced in this example) and to go on after a warning message is found. I've tried with invokeRestart function, but it doesn't work. Any tips?? testTryCatch<-function() { myWarnings <- NULL tryCatch({ a<-3 b<-a+6 warning("hello1") c<-6+13 warning("hello2") return(c) },warning=function(ex){ myWarnings <<- c(myWarnings, list(ex)) #some code (like invokeRestart("muffleWarning")) to go on executing in c<-6+13, but it doesn't work },error=function(ex){ cat("error found") },finally={ print(myWarnings) } ) } Thanks, Javier
GO GO • 1.5k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 15 days ago
United States
Hi Javier -- Javier P?rez Florido wrote: > Dear list, > I have a code sample in which a single assignment is returned. What I > want to do is to collect all warning messages found in the example (they > are forced in this example) and to go on after a warning message is > found. I've tried with invokeRestart function, but it doesn't work. Any > tips?? ?withCallingHandlers; there's an example on the help page. withCallingHandlers({ warning("A"); 1+2 }, warning = function(w) {}) Martin > > testTryCatch<-function() > { > myWarnings <- NULL > > tryCatch({ > a<-3 > b<-a+6 > warning("hello1") > c<-6+13 > warning("hello2") > return(c) > },warning=function(ex){ > myWarnings <<- c(myWarnings, list(ex)) #some code > (like invokeRestart("muffleWarning")) to go on executing in c<-6+13, but > it doesn't work > },error=function(ex){ > cat("error found") > },finally={ > print(myWarnings) } > ) > > } > > Thanks, > Javier > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793
ADD COMMENT

Login before adding your answer.

Traffic: 613 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6