Possible Duplicate:
Exception handling in R
Does anyone have idea on how to catch an error or an exception in R?
Like Joshua said: use tryCatch
. Include an error
argument, which should be a function accepting one parameter (the error, typically called e
).
tryCatch(
stop("you threw an error"),
error = function(e)
{
print(e$message) # or whatever error handling code you want
}
)
It really depends on what you mean by "catch". Look at tryCatch
and withCallingHandlers
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With