Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tryCatch suppress error message

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?

like image 283
Alex Avatar asked Apr 17 '16 22:04

Alex


People also ask

How do I suppress an error in R?

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() .

What does tryCatch return in R?

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.


1 Answers

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) {})

like image 103
jaimedash Avatar answered Nov 15 '22 09:11

jaimedash