I was surprised by difference between using options(error=browser) and options(error=recover) when handling an error from sys.frame that I assume is related to the fact that the error is thrown from the .Internal and the 'which' parameter to the closure isn't available.

> options(error=browser)
> f <- function() sys.frame(-3)
> f()
Error in sys.frame(-3) : not that many frames on the stack
Called from: sys.frame(-3)
Browse[1]> where
where 1 at #1: sys.frame(-3)
where 2: f()

Browse[1]> print(which)
function (x, arr.ind = FALSE, useNames = TRUE)
{
    wh <- .Internal(which(x))
    if (arr.ind && !is.null(d <- dim(x)))
        arrayInd(wh, d, dimnames(x), useNames = useNames)
    else wh
}
<bytecode: 0x7fe7a43f1260>
<environment: namespace:base>

Whereas:

> options(error=recover)
> f()
Error in sys.frame(-3) : not that many frames on the stack

Enter a frame number, or 0 to exit

1: f()
2: #1: sys.frame(-3)

Selection: 2
Called from: top level
Browse[1]> print(which)
[1] -3
Browse[1]>

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to