From 09d6ddafe7ef18fb0776de82cc863ffe1006a9a2 Mon Sep 17 00:00:00 2001 From: Christian Autermann Date: Thu, 5 Mar 2015 11:58:48 +0100 Subject: [PATCH 1/3] added missing NULL --- R/class-unions.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/class-unions.R b/R/class-unions.R index 24e47f9..929a4e3 100644 --- a/R/class-unions.R +++ b/R/class-unions.R @@ -1,6 +1,8 @@ library(sp) + #' @import sp +NULL setClassUnion("character_or_NULL", c("character", "NULL")) setClassUnion("numeric_or_NULL", c("numeric", "NULL")) From ea064c90a886c6a1bcd0386ab5d76bee40d2d3e3 Mon Sep 17 00:00:00 2001 From: Christian Autermann Date: Thu, 5 Mar 2015 11:59:03 +0100 Subject: [PATCH 2/3] added missing documentation --- R/query-methods.R | 2 +- man/distance-matrix-methods.Rd | 4 ++-- man/query-methods.Rd | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/R/query-methods.R b/R/query-methods.R index 653036b..0800878 100644 --- a/R/query-methods.R +++ b/R/query-methods.R @@ -368,7 +368,7 @@ setMethod("fetch", x }) - +#' @param generalize Generalize the data on server side. #' @rdname query-methods setMethod("getData", signature(x = "Timeseries"), diff --git a/man/distance-matrix-methods.Rd b/man/distance-matrix-methods.Rd index 96861a4..007016b 100644 --- a/man/distance-matrix-methods.Rd +++ b/man/distance-matrix-methods.Rd @@ -64,7 +64,7 @@ to \code{x}, enriched with an additional distance attribute. For \code{distanceMatrix} and \code{readDistanceMatrix}: a distance matrix of class \code{dist}. -For \code{distnace}: a numeric vector containing the distance in meters. +For \code{distance}: a numeric vector containing the distance in meters. } \description{ Methods to calculate distances between objects and to find the geographically @@ -82,7 +82,7 @@ returned vector or vectorized object is sorted by their distance to \code{x}. Additionally the distance can be obtained using \code{distance}. The distance is calculated using computations on an ellipsoid and the -returned are meters. +returned value is in meters. } \examples{ endpoint <- example.endpoints()[2] 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{ From a62b1a5f1c22253bb53491cb4329d6f5df1af713 Mon Sep 17 00:00:00 2001 From: Christian Autermann Date: Thu, 5 Mar 2015 13:06:00 +0100 Subject: [PATCH 3/3] added try-catch and better error handling to get.json --- R/query-methods.R | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/R/query-methods.R b/R/query-methods.R index 25cf3f7..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)