Displaying 1 result from an estimated 1 matches for "on_warning".
Did you mean:
i_warning
2011 May 10
0
Debugging warnings
...er)). But it should be
possible to use withCallingHandlers to provide more flexibility. The
function below works, but I'm wondering if there's a more elegant way
to figure out the correct frame to evaluate the action in - I'm
currently counting back one from where warning was called.
on_warning <- function(action, code) {
q_action <- substitute(action)
withCallingHandlers(code, warning = function(c) {
for(i in seq_len(sys.nframe())) {
f <- as.character(sys.call(i)[[1]])
if (f == "warning") break;
}
eval(q_action, sys.frame(i - 1))
})
}
x...