From 6c0263d82d97cc1a211fcc3cbf307edb7b7ce69e Mon Sep 17 00:00:00 2001 From: Gabor Csardi Date: Thu, 9 Apr 2015 10:20:11 -0400 Subject: [PATCH] Better handling of "errors" from the server Server really shouldn't return 200 for these, though. --- R/cranlogs.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/cranlogs.R b/R/cranlogs.R index 537945c..d083b7e 100644 --- a/R/cranlogs.R +++ b/R/cranlogs.R @@ -68,6 +68,10 @@ cran_downloads <- function(packages = NULL, r <- fromJSON(content(GET(paste0(url, interval, packages)), as = "text"), simplifyVector = FALSE) + if ("error" %in% names(r) && r$error == "Invalid query") { + stop("Invalid query, probably invalid dates") + } + to_df(r) }