Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error handler fails silently in some cases #70

Closed
flying-sheep opened this issue Aug 2, 2016 · 3 comments
Closed

error handler fails silently in some cases #70

flying-sheep opened this issue Aug 2, 2016 · 3 comments

Comments

@flying-sheep
Copy link
Contributor

the following code prints a empty list() although the list should contain the recursion error:

err <- list()
eh <- function(e) err <<- c(err, list(toString(e)))
oh <- evaluate::new_output_handler(error = eh)
evaluate::evaluate(
    'f<-function(x) f(x); f(0)',
    output_handler = oh,
    envir = .GlobalEnv,
    stop_on_error = 1L)
print(err)

if we however do eh <- function(e) err <<- c(err, list(e)), it’ll work. why?

@flying-sheep flying-sheep changed the title weird error handler fails silently in some cases Aug 2, 2016
@flying-sheep
Copy link
Contributor Author

since @yihui said he has no idea, i thought about it some more…

maybe toString does something depending on the global stack trace info and somehow fails in the error function? maybe it can be debugged by writing stuff to a file (since the stdout/err capturing of evaluate interferes otherwise)

@flying-sheep
Copy link
Contributor Author

hmm…

eh <- function(e) {
    p <- pipe('cat', 'w')
    write('this works', p)
    tryCatch(
        toString(e),
        error = function(err) write('this doesn’t', p),
        finally = write('this neither', p))
    write('this isn’t reached', p)
    close(p)
    err <<- c(err, list(toString(e)))
}

@hadley
Copy link
Member

hadley commented Jun 14, 2024

When I run this now, I get:

Error : C stack usage  7954168 is too close to the limit

Likely related to #103

@hadley hadley closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants