R/pxweb_parse_url_or_fail.R

Defines functions parse_url_or_fail

Documented in parse_url_or_fail

#' Parse a character string or throws error if it fails
#' 
#' @param x a character element to parse
#' 
#' @keywords internal
parse_url_or_fail <- function(x){
  checkmate::assert_string(x)
  x <- pxweb_fix_url(x)
  parsed_url <- httr::parse_url(x)
  if(is.null(parsed_url$hostname)){
    stop("Cannot parse url (hostname). Please check url for potential errors (?parse_url): '", x,"'", call. = FALSE)
  }
  parsed_url
}

Try the pxweb package in your browser

Any scripts or data that you put into this service are public.

pxweb documentation built on Oct. 31, 2022, 5:07 p.m.