Skip to content

Commit

Permalink
Catch a rare error
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Dec 20, 2023
1 parent 1052dce commit 872b082
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* added resolve_phylopic (#66)
* pick_phylopic now accepts a list of uuids via the uuid argument (#95)
* fixed check behavior on CRAN (all tests and examples are now skipped)
* caught a rare error when nothing matched `filter`

# rphylopic 1.2.2

Expand Down
6 changes: 5 additions & 1 deletion R/get_uuid.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ get_uuid <- function(name = NULL, img = NULL, n = 1, filter = NULL,
if ("nc" %in% filter) opts$filter_license_nc <- "false"
if ("sa" %in% filter) opts$filter_license_sa <- "false"
api_return <- phy_GET("images", opts)
total_items <- api_return$totalItems
if ("totalItems" %in% names(api_return)) {
total_items <- api_return$totalItems
} else {
stop("No images matching the specified `filter`.")
}
if (total_items < n) {
warning(paste0("Only ", total_items, " item(s) are available."))
n <- total_items
Expand Down

0 comments on commit 872b082

Please sign in to comment.