I am trying to write a function to handle execution of batch jobs, logging errors and stats of the job results.
Is there a way to reference returning value of expr block, from finally block?
my_do <- function(FUN, ...){
result <- tryCatch({
FUN(...)
},
error = function(e) {
message("error.")
},
finaly = {
# how can I reference the returning value of FUN(...) in finally block?
# so for example, I can write code like this:
message(paste("Result dimensions:", dim(expr_result)))
},
)
return(result)
}