Repository navigation
More informative diagnostics from github_remotes() - #2230
Conversation
| get_gh_repo | ||
| ) | ||
|
|
||
| repo_info <- unwrap_purrr(purrr::pmap( |
There was a problem hiding this comment.
Explicitly unwrapping the purrr error here since get_gh_repo() already includes all the context needed.
| oops_remotes <- grl$remote[oops] | ||
| oops_hosts <- unique(grl$host[oops]) | ||
| ui_abort(c( | ||
| "Unable to get GitHub info for these remotes: {.val {oops_remotes}}.", |
There was a problem hiding this comment.
The new behaviour is to error on the first remote that fails, which is maybe a small downgrade in experience, but I don't think it's significant.
| } | ||
| } | ||
|
|
||
| gh_repo_fail_message <- function(cnd, api_url) { |
There was a problem hiding this comment.
These errors (and accompanying snapshots) are probably the most important place to spend your review energy.
| github_remote_config <- function(github_get = NA, call = caller_env()) { | ||
| cfg <- new_github_remote_config() | ||
| grl <- github_remotes(github_get = github_get) | ||
| grl <- github_remotes(github_get = github_get, call = call) |
There was a problem hiding this comment.
Ensures that (e.g.) pr_pull() reports pr_pull() in the error message.
jennybc
left a comment
There was a problem hiding this comment.
LGTM. I made a few inline comments.
My only source of some discomfort is kind of hard-wiring specific interpretations of specific HTTP codes. Of course everything looks/feel right and we are surfacing the more nitty gritty details of the error. I just wouldn't be surprised if we say something a bit off base or confusing now or in the future. But this is absolutely more and better info than usethis currently provides!
| github_get = TRUE, | ||
| call = caller_env() | ||
| ) { | ||
| # Don't even try to get parent info for missing remote |
There was a problem hiding this comment.
This comment seems to not really describe the if () condition, meaning remote != owner, name.
Also looks like we can early exit here for github_get is FALSE.
There was a problem hiding this comment.
Comment improved. I think it's clearer to handle the three github_get() values in one place below.
| } | ||
|
|
||
| if (identical(github_get, TRUE)) { | ||
| # Fail with informative message |
There was a problem hiding this comment.
Speaking for myself, maybe a comment about why we need withCallingHandlers() (vs. tryCatch()) is more useful than this? I did have to read up on this FWIW. Or no comment.
There was a problem hiding this comment.
I'm not sure where we document that but you should always use withCallingHandlers() when wrapping errors.
We more carefully generate an error based on the specific error condition, always including the original error for context.
Fixes #2229. Fixes #1929.