error checks
On 11/13/09 8:02 AM, Tony Plate wrote:
Putting options(error=function() NULL) at the start of the .R will let R CMD check continue with commands in a file after stop() is called. (Or anything other than the default options(error=NULL)).
But that's a rather heavy handed approach and could easily mask errors
that you are not expecting.
Instead, how about using tryCatch so that you limit the errors that you
trap and also can verify that an error was indeed trapped. Perhaps
something like this:
f <- function(x) if (x) stop("crash!") else NULL
res <- tryCatch(
{
f(TRUE) # this will raise an error
FALSE # only get here if no error
},
error = function(e) TRUE)
## verify we saw an error
stopifnot(res)
+ seth
Seth Falcon | @sfalcon | http://userprimary.net/users