R/errors.R

Defines functions missing_column_error date_format_error request_error

Documented in date_format_error missing_column_error request_error

### Package errors

#' Report an error with an http request
#'
#' @param response The text of the server reponse.
#' @keywords internal

request_error <- function(response) {
    stringr::str_glue(
        "The server responded with the following message: {response}")
}

#' Report an error parsing a date string
#'
#' @param date_str The date string that could not be parsed.
#' @keywords internal

date_format_error <- function(date_str) {
    stringr::str_glue(stringr::str_c(
        "{date_str} is not a valid Date or ",
        "date string: use format \"YYYY-MM-DD\""))
}

#' Report an error handling dataframes with missing columms
#'
#' @param colname The name of the column that could not be found.
#' @keywords internal

missing_column_error <- function(colname) {
    stringr::str_glue("Could not find a column called {colname}")
}
houseofcommonslibrary/pdpr documentation built on Sept. 14, 2020, 12:04 a.m.