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

Better tracebacks #3510

Closed
krlmlr opened this issue Apr 12, 2018 · 4 comments
Closed

Better tracebacks #3510

krlmlr opened this issue Apr 12, 2018 · 4 comments
Labels
feature a feature request or enhancement

Comments

@krlmlr
Copy link
Member

krlmlr commented Apr 12, 2018

When a complex expression inside mutate() or most other verbs fails, the traceback is not informative:

library(tidyverse)
f <- function(x) if (x < 3) 5 else g()
g <- function() stop("oops")
tibble(a = 1:10) %>% group_by(a) %>% mutate(b = f(a))
#> Error in mutate_impl(.data, dots): Evaluation error: oops.

Created on 2018-04-12 by the reprex package (v0.2.0).

It does contain the error message, but not the location. I wonder if the traceback can be made available.

If not, we could fix this by creating unrolled optimized R code in the C++ part, which then is passed to the R evaluator, and then transforming the results in C++ again:

mutate <- function(.data, ...) {
  code <- unroll_mutate(.data, !!!quos(...))
  res <- eval(code)
  apply_mutate(.data, res)
}
@krlmlr krlmlr added feature a feature request or enhancement data frame labels Apr 12, 2018
@romainfrancois
Copy link
Member

Sounds like this could be an r-lib project in its own.

@krlmlr
Copy link
Member Author

krlmlr commented May 2, 2018

Maybe if we try {} catch {} at the C++ level? Is there a way to do Go-style evaluation in Rcpp, returning the result or an exception?

@romainfrancois
Copy link
Member

For now, we will replace this by #3662

@lock
Copy link

lock bot commented Dec 8, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Dec 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants