diff --git a/R/class-unions.R b/R/class-unions.R index 9c34710..5a8df0d 100644 --- a/R/class-unions.R +++ b/R/class-unions.R @@ -1,5 +1,3 @@ - - setClassUnion("character_or_NULL", c("character", "NULL")) setClassUnion("numeric_or_NULL", c("numeric", "NULL")) setClassUnion("logical_or_NULL", c("logical", "NULL")) diff --git a/R/query-methods.R b/R/query-methods.R index 3e4abf0..ca4c189 100644 --- a/R/query-methods.R +++ b/R/query-methods.R @@ -101,8 +101,16 @@ get.json <- function(url, ...) { q <- ifelse(!is.null(p$query), do.call(as.query.string, p$query), "") futile.logger::flog.debug("Requesting %s?%s", url, q) response <- httr::GET(url, httr::add_headers(Accept="application/json"), ...) - httr::stop_for_status(response) - jsonlite::fromJSON(httr::content(response, "text")) + content <- httr::content(response, "text") + + tryCatch(httr::stop_for_status(response), + error = function(err) { + message <- paste0("Error requesting '",url,"?",q,"': ", err, "\n", content) + futile.logger::flog.error(message); + stop(message) + }) + + jsonlite::fromJSON(content) } get.and.parse <- function(endpoint, query, fun.url, fun.parse) @@ -368,7 +376,7 @@ setMethod("fetch", x }) - +#' @param generalize Generalize the data on server side. #' @rdname query-methods setMethod("getData", signature(x = "Timeseries"), diff --git a/man/query-methods.Rd b/man/query-methods.Rd index b009c4e..b9a3bf6 100644 --- a/man/query-methods.Rd +++ b/man/query-methods.Rd @@ -102,6 +102,8 @@ getData(x, ...) \S4method{getData}{Timeseries}(x, generalize = FALSE, timespan = NULL, ...) } \arguments{ +\item{generalize}{Generalize the data on server side.} + \item{timespan}{A \linkS4class{Interval} or a character vector to filter with.} } \description{