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

Improve an error message in visc_load_pdata() #253

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.*"
)
})
})
Loading