withCallingHandlers works similar to tryCatch but
- remembers the call stack down to the point where the condition was signaled
- resumes the execution after the point where the condition was signaled
f <- function() {
warning("deprecated function called")
print("Hello world")
}
withCallingHandlers(f(), warning = function(w) { write.to.log(sys.calls()) })
## Warning in f(): deprecated function called
## [1] "Hello world"