I am using tryCatch
to catch any errors that occur. However, even though I catch them and return the appropriate error value, it looks like the error is still reported in the logs of my batch system. Is there a way to completely suppress the error and simply proceed with the error handling I provide?
The simplest way of handling conditions in R is to simply ignore them: Ignore errors with try() . Ignore warnings with suppressWarnings() . Ignore messages with suppressMessages() .
You can use a tryCatch() function in R to return the value of some expression or produce a custom message if a warning or error is encountered.
Make sure you're neither (1) returning an error, nor (2) printing to stderr
in your error handling code. Note one gotcha here is message
sends its output to stderr
.
A minimal way to fulfills both conditions is tryCatch(expr, error = function(e) {})
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