I have a variable declaration inside of an error function of a tryCatch
function. But when the error is triggered, the variable declaration is not performed, even though the error message is successfully output.
tryCatch({ var_binned_names = arules::discretize(Xt,
method = arules_method,
breaks = num_breaks,
ordered = TRUE)
}, error = function(error) {
cat("Error: could not discretize numeric", numeric_i, "", name, "\n")
cat("Unique values:", length(unique(Xt)), "\n")
var_binned_names = Xt
})
One would expect that, when var_binned_names
is failed to be assigned due to an error with discretize, that it would get assigned Xt
in the error function. However, what happens is that it's not defined.