Closed stephhazlitt closed 1 year ago
The above example errores because it fails to detect the BCDC records with the term "ambulatory" due to the default for download_audience
being Public
(and the ambulatory records are download_audience = "Not downloadable"
). However, the error happens anytime 0 records are detected, e.g.,
bcdata::bcdc_search("pumpkin")
#> List of B.C. Data Catalogue Records
#> Number of records: 0
#> Titles:
#> Error in `map2()`:
#> ℹ In index: 1.
#> Caused by error in `x[[.y]]`:
#> ! subscript out of bounds
#> Backtrace:
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. ├─global `<fn>`(input = base::quote("pure-tayra_reprex.R"))
#> 13. │ └─rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#> 14. │ └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#> 15. │ └─knitr:::process_file(text, output)
#> 16. │ ├─base::withCallingHandlers(...)
#> 17. │ ├─knitr:::process_group(group)
#> 18. │ └─knitr:::process_group.block(group)
#> 19. │ └─knitr:::call_block(x)
#> 20. │ └─knitr:::block_exec(params)
#> 21. │ └─knitr:::eng_r(options)
#> 22. │ ├─knitr:::in_input_dir(...)
#> 23. │ │ └─knitr:::in_dir(input_dir(), expr)
#> 24. │ └─knitr (local) evaluate(...)
#> 25. │ └─evaluate::evaluate(...)
#> 26. │ └─evaluate:::evaluate_call(...)
#> 27. │ ├─evaluate (local) handle(...)
#> 28. │ │ └─base::try(f, silent = TRUE)
#> 29. │ │ └─base::tryCatch(...)
#> 30. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 31. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 32. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 33. │ ├─base::withCallingHandlers(...)
#> 34. │ ├─base::withVisible(value_fun(ev$value, ev$visible))
#> 35. │ └─knitr (local) value_fun(ev$value, ev$visible)
#> 36. │ └─knitr (local) fun(x, options = options)
#> 37. │ ├─base::withVisible(knit_print(x, ...))
#> 38. │ ├─knitr::knit_print(x, ...)
#> 39. │ └─knitr:::knit_print.default(x, ...)
#> 40. │ └─evaluate (local) normal_print(x)
#> 41. │ ├─base::print(x)
#> 42. │ └─bcdata:::print.bcdc_recordlist(x)
#> 43. │ └─purrr::imap(...) at bcdata/R/utils-classes.R:142:2
#> 44. │ └─purrr::map2(.x, vec_index(.x), .f, ...)
#> 45. │ └─purrr:::map2_("list", .x, .y, .f, ..., .progress = .progress)
#> 46. │ ├─purrr:::with_indexed_errors(...)
#> 47. │ │ └─base::withCallingHandlers(...)
#> 48. │ ├─purrr:::call_with_cleanup(...)
#> 49. │ └─bcdata (local) .f(.x[[i]], .y[[i]], ...)
#> 50. │ ├─base::nrow(bcdc_tidy_resources(x[[.y]])) at bcdata/R/utils-classes.R:144:4
#> 51. │ └─bcdata::bcdc_tidy_resources(x[[.y]])
#> 52. └─purrr (local) `<fn>`(`<sbscOOBE>`) at bcdata/R/bcdc_search.R:324:2
#> 53. └─cli::cli_abort(...)
#> 54. └─rlang::abort(...)
Created on 2023-03-01 with reprex v2.0.2
Created on 2023-03-01 with reprex v2.0.2