method_with_error <- function() {
tryCatch(stop("test exception"),
error = function(e) {
# Любая частичная обработка здесь,
# затем ошибка идёт дальше
stop(e)
})
}
msg <- tryCatch(method_with_error(),
error = conditionMessage)
# msg = test exception
cat("msg =", msg, "\n")