Skip to content

Commit

Permalink
Merge pull request #253 from FredHutch/visc_load_pdata_error
Browse files Browse the repository at this point in the history
Improve an error message in visc_load_pdata()
  • Loading branch information
slager authored Dec 10, 2024
2 parents daa8494 + 1264b0b commit 4bdaa31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bug fixes
* Provide default CRAN mirror if missing in install_load_cran_packages(), e.g., in a child R session during knitting. Fixes 'trying to use CRAN without setting a mirror' error (#218)
* Update template.tex so that flextable package can be used to create tables in PDF documents (#226)
* Clean up invalid ORCID placeholder generated by usethis 3.0.0 that threw error on R version 4.5.x (#248)
* Include pdata object name and data package name in visc_load_pdata() error message (#252)

Other improvements
* create_visc_project() now discards README.Rmd after knitting template to README.md (#223)
Expand Down
8 changes: 7 additions & 1 deletion R/visc_load_pdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ visc_load_pdata <- function(.data,
lazyLoad(filebase = system.file(file.path('data', 'Rdata'),
package = pkg_name), envir = pdata_env)
} else {
stop('Unable to find data object file')
stop(
sprintf(
"Unable to find data object '%s' in package '%s'",
pdata_name,
pkg_name
)
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-visc_load_pdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test_that("visc_load_pdata works", {
'3ccb5b0aaa74fe7cfc0d3ca6ab0b5cf3'
)
}),
"Unable to find data object file"
"Unable to find data object.*"
)
})
})

0 comments on commit 4bdaa31

Please sign in to comment.