powered by
Evaluate code with unified error handling (and consistent warning reporting). On error, prints a CLI message (unless quiet = TRUE) and returns NULL.
quiet = TRUE
NULL
safe_execute(expr, fail_message = "An error occurred", quiet = FALSE)
The result of the expression if successful; otherwise NULL.
Code to evaluate.
Message to display if an error occurs. Default: "An error occurred".
Logical. If TRUE, suppress messages. Default: FALSE.
TRUE
FALSE
safe_execute(log(1)) safe_execute(log("a"), fail_message = "Failed to compute log")
Run the code above in your browser using DataLab