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 errors for @includeRmd #1089

Closed
lionel- opened this issue Apr 30, 2020 · 9 comments · Fixed by #1397
Closed

Better errors for @includeRmd #1089

lionel- opened this issue Apr 30, 2020 · 9 comments · Fixed by #1397
Labels
bug an unexpected problem or unintended behavior rd ✍️
Milestone

Comments

@lionel-
Copy link
Member

lionel- commented Apr 30, 2020

I'm debugging errors that occur during #' @includeRmd. The NAMESPACE file is emptied at each error, and I need to reset it manually. Would it make sense to restore it to its original contents in case of error?

@gaborcsardi
Copy link
Member

gaborcsardi commented Apr 30, 2020

Interesting. I think it would be even better not to touch it when the Rd roclet is running. Or not to touch it at all, until the new contents of NAMESPACE is compiled.

Do you have a reprex procedure for this?

@lionel-
Copy link
Member Author

lionel- commented Apr 30, 2020

#' Stop
#' @includeRmd "R/stop.Rmd"
#' @name stop
NULL

With stop.Rmd:

```{r}
stop("foo")
```

Another case where that comes up is when I interrupt document() after it has emptied the NAMESPACE.

@lionel-
Copy link
Member Author

lionel- commented Apr 30, 2020

By the way it might be less confusing to output "Emptying NAMESPACE" the first time, rather than "Writing NAMESPACE" twice.

@hadley
Copy link
Member

hadley commented May 1, 2020

I think the @includeRmd code probably needs a tryCatch?

@hadley hadley added bug an unexpected problem or unintended behavior rd ✍️ labels May 1, 2020
@lionel-
Copy link
Member Author

lionel- commented May 1, 2020

We'd want document() to fail if the Rmd fails unexpectedly though?

@hadley
Copy link
Member

hadley commented May 1, 2020

I think it would emit a warning, like how other tags "fail"

@gaborcsardi
Copy link
Member

IDK, this is a bit different, though, no? I think I usually want an error when the dynamic code fails.

@hadley
Copy link
Member

hadley commented May 1, 2020

Maaaaybe, but I think it's better to be consistent.

@hadley hadley added this to the 7.2.1 milestone Jul 10, 2022
@hadley
Copy link
Member

hadley commented Jul 10, 2022

It's more clear now that this should fail with a warning since that's what child documents do.

@hadley hadley changed the title Restore NAMESPACE file if errored Better errors for @includeRmd Jul 11, 2022
hadley added a commit that referenced this issue Jul 11, 2022
hadley added a commit that referenced this issue Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior rd ✍️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants