I have been reading through the answers on SO about how to use tryCatch
. I really don't understand where the c
variable comes from though.
e.g. (via http://adv-r.had.co.nz/Exceptions-Debugging.html#condition-handling)
show_condition <- function(code) {
tryCatch(code,
error = function(c) "error",
warning = function(c) "warning",
message = function(c) "message"
)
}
show_condition(stop("!"))
#> [1] "error"
show_condition(warning("?!"))
#> [1] "warning"
show_condition(message("?"))
#> [1] "message"
# If no condition is captured, tryCatch returns the
# value of the input
show_condition(10)
#> [1] 10
Is c
a system variable? Elsewhere others seems to use e
in its place?