From 6fcc84338752d9194fb8e1195de2915a89c85fbf Mon Sep 17 00:00:00 2001 From: buhly Date: Sun, 11 Aug 2024 16:41:07 +0200 Subject: [PATCH] fix bugs in gen_table --- R/gen_table.R | 2 +- R/utils_httr2.R | 14 +++++++++++--- README.Rmd | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/R/gen_table.R b/R/gen_table.R index cf628b5..38a3225 100644 --- a/R/gen_table.R +++ b/R/gen_table.R @@ -110,7 +110,7 @@ gen_table_ <- function(name, #----------------------------------------------------------------------------- # Data download - if(database == "zensus"){ + if (database == "zensus"){ response <- gen_zensus_api("data/tablefile", name = name, diff --git a/R/utils_httr2.R b/R/utils_httr2.R index 4e5929c..73fb9f6 100644 --- a/R/utils_httr2.R +++ b/R/utils_httr2.R @@ -276,21 +276,29 @@ return_table_object <- function(response, "Consider making a range of smaller requests or use the \n", "option to create a job by setting the 'job' parameter \n", "of 'gen_table()' to TRUE. You can then download the job \n", - "later (use the function 'gen_list_jobs()' to check its status).") + "later (use the function 'gen_list_jobs()' to check its status) \n", + "and download it using gen_download_job().") stop(error_message, call. = FALSE) } else if (response_parsed$Status$Code == 99) { - message <- paste0("You have requested successfully created a job with \n", + message <- paste0("You have successfully created a job with \n", "your request. Use the function 'gen_list_jobs()' ", "to check its status and download it once completed.") message(message) + } else if (response_parsed$Status$Code == 104) { + + stop("There are no results for your request. Please check if the requested table code is valid for the database selected.", + call. = FALSE) + } else { - stop("There has been an error with your request (not parseable response type 'application/json').\n Please try again later or contact the package maintainer.", + stop(paste0("There has been an error with your request (API error code: '", + response_parsed$Status$Code, + "').\n Please try again later or contact the package maintainer."), call. = FALSE) } diff --git a/README.Rmd b/README.Rmd index 1591c2e..55d6e44 100644 --- a/README.Rmd +++ b/README.Rmd @@ -72,7 +72,7 @@ In a short overview, there are functions divided in two main parts, searching fo #### Other functions - **gen_logincheck()**: Perform a logincheck to test your credentials -- **gen_qualitysigns()**: Get a list of quality signs (special characters) found in the API's tables +- **gen_signs()**: Get a list of quality signs (special characters) found in the API's tables - **gen_update_evas()**: Manually scrape a newer version of the EVAS numbers (official statistic IDs) ### Caching