[BioC] tryCatch: go on executing after a warning message

Javier Pérez Florido jpflorido at gmail.com
Sat Dec 12 13:25:46 CET 2009


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



More information about the Bioconductor mailing list