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