When to use Try Catch blocks

It seems to me that this topic is very strange and confused. Could someone lights me up? Definitely. I’m not a PHP user, but I might have a little insight after having worked with try/catch in ActionScript, Java, and JavaScript. Bear in mind though, that different languages and platforms encourage different uses for try/catch. That … Read more

What are the circumstances under which a finally {} block will NOT execute?

If you call System.exit() the program exits immediately without finally being called. A JVM Crash e.g. Segmentation Fault, will also prevent finally being called. i.e. the JVM stops immediately at this point and produces a crash report. An infinite loop would also prevent a finally being called. The finally block is always called when a … Read more

How to tell lapply to ignore an error and process the next thing in the list?

Use a tryCatch expression around the function that can throw the error message: testFunction <- function (date_in) { return(tryCatch(as.Date(date_in), error=function(e) NULL)) } The nice thing about the tryCatch function is that you can decide what to do in the case of an error (in this case, return NULL). > lapply(dates2, testFunction) [[1]] [1] “2010-04-06” [[2]] … Read more