[R] Hard Stop?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Feb 7 19:25:32 CET 2013


On 06/02/2013 8:33 PM, ivo welch wrote:
> is it possible to throw a stop() that is so hard that it will escape
> even tryCatch?

You can signal a condition that is not an error, and if tryCatch hasn't 
been written to catch it, it will stop.   For example,

g <- function() {
   tryCatch(f(), error=function(e) NULL
   cat("Still running\n")
}

f <- function() stop("Regular error")  # This won't stop g()
g()


f  <- function() stop(simpleCondition("I mean it!")) # This will
g()

Of course, you can catch simpleConditions too if you try.

Duncan Murdoch



More information about the R-help mailing list