rOpenGov / eurostat

R tools for Eurostat data
http://ropengov.github.io/eurostat
Other
234 stars 46 forks source link

More informative error messages #286

Open pitkant opened 8 months ago

pitkant commented 8 months ago

The following query does not return any error message:

> eurostat::get_eurostat("road_go_ia_rc", filters=list(unit = c("THS_T")), cache = FALSE)
Error in get_eurostat_json(id, filters, type, lang, stringsAsFactors,  : 

Obviously it should output a message that would contain the following information as parsed text:

{ "error": [{"status": 413,"id": 413,"label": "EXTRACTION_TOO_BIG: The requested extraction is too big, estimated 5101056 rows, max authorised is 5000000, please change your filters to reduce the extraction size"}]}
> eurostat::get_eurostat("road_go_ia_rc2", filters=list(unit = c("THS_T")), cache = FALSE)
Error in get_eurostat_json(id, filters, type, lang, stringsAsFactors,  : 
  HTTP status: 404 (Not found)
  Error id: 100 (No results found)
  Error label from API: ERR_NOT_FOUND_4: ROAD_GO_IA_RC2 (DATA_SET:ESTAT,1.0) is not available for dissemination.

The package currently handles "Error messages returned in case of invalid queries" but it should account for all other types of error messages as well.

sessionInfo R version 4.3.2 (2023-10-31) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Sonoma 14.2.1 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0 locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: Europe/Helsinki tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tidyr_1.3.0 rappdirs_0.3.3 utf8_1.2.3 generics_0.1.3 class_7.3-22 [6] xml2_1.3.5 KernSmooth_2.23-22 stringi_1.7.12 hms_1.1.3 digest_0.6.33 [11] magrittr_2.0.3 countrycode_1.5.0 timechange_0.2.0 ISOweek_0.6-2 cellranger_1.1.0 [16] rprojroot_2.0.3 plyr_1.8.9 jsonlite_1.8.7 e1071_1.7-13 backports_1.4.1 [21] httr_1.4.7 eurostat_4.0.0 purrr_1.0.2 fansi_1.0.5 regions_0.1.8 [26] XML_3.99-0.14 bibtex_0.5.1 httr2_0.2.3 cli_3.6.1 crayon_1.5.2 [31] rlang_1.1.1 bit64_4.0.5 withr_2.5.1 parallel_4.3.2 tools_4.3.2 [36] tzdb_0.4.0 dplyr_1.1.3 here_1.0.1 curl_5.1.0 assertthat_0.2.1 [41] vctrs_0.6.4 R6_2.5.1 proxy_0.4-27 lifecycle_1.0.3 lubridate_1.9.3 [46] classInt_0.4-10 rsdmx_0.6-3 RefManageR_1.4.0 stringr_1.5.0 bit_4.0.5 [51] vroom_1.6.4 pkgconfig_2.0.3 pillar_1.9.0 data.table_1.14.8 glue_1.6.2 [56] Rcpp_1.0.11 tibble_3.2.1 tidyselect_1.2.0 rstudioapi_0.15.0 readr_2.1.4 [61] compiler_4.3.2 readxl_1.4.3