A wrapper around base try that allows you to set a custom message when an error/warning occurs. attempt returns the value if there is no error nor message.
attempt
attempt(expr, msg = NULL, verbose = FALSE, silent = FALSE)
the expression to be evaluated
the message to return if an error occurs
wether or not to return to expression producing the error
wether or not the error should be kept under silence
# NOT RUN { attempt(log("a"), msg = "Nop !") # }
Run the code above in your browser using DataLab