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

more informative error message when census api fails #19

Closed
medewitt opened this issue May 9, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@medewitt
Copy link
Owner

commented May 9, 2019

Need to update the check_census_api_call to something like the following to make it clear when the census fails and not the package:

check_census_api_call <- function(call){
  if(class(call) != "response"){
    stop("A valid response was not returned")
  }
returned_call <- httr::content(call, as = "text", encoding = "UTF-8")

if( show_condition(xml2::as_xml_document(returned_call)) !="error"){
  returned_call %>%
    xml2::as_xml_document()%>%
    xml2::xml_find_all("body") %>%
    xml2::xml_text() %>%
    gsub(pattern = "\\s{2}", replacement = "") %>%
    gsub(pattern = "^\\s", replacement = "")
} else{
  stop(paste0("The following is a message from the US Census API \n",returned_call ))
}
}
@medewitt

This comment has been minimized.

Copy link
Owner Author

commented May 9, 2019

Close with #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.