rlang icon indicating copy to clipboard operation
rlang copied to clipboard

Internal errors should attempt to link to the package `BugReports` URL

Open DavisVaughan opened this issue 1 year ago • 0 comments

I think we should be able to get it somewhat reliably with something like this

unstructure <- function(x) {
  attributes(x) <- NULL
  x
}

get_bug_reports_url <- function(pkg) {
  tryCatch({
    file <- system.file("DESCRIPTION", package = pkg, mustWork = TRUE)
    
    url <- read.dcf(file, fields = "BugReports")
    url <- unstructure(url)
    
    rlang:::check_string(url)
    
    url
  },
  error = function(cnd) {
    NULL
  })
}

get_bug_reports_url("yardstick")
#> [1] "https://github.com/tidymodels/yardstick/issues"

Then something like this?

ℹ This is an internal error in the yardstick package, please [report it](url) to the package authors.

I had someone send me an email about yardstick after seeing an internal error

DavisVaughan avatar Aug 26 '22 12:08 DavisVaughan