Permalink
Browse files

Better handling of "errors" from the server

Server really shouldn't return 200 for these, though.
  • Loading branch information...
1 parent 68a38c1 commit 6c0263d82d97cc1a211fcc3cbf307edb7b7ce69e @gaborcsardi gaborcsardi committed Apr 9, 2015
Showing with 4 additions and 0 deletions.
  1. +4 −0 R/cranlogs.R
View
@@ -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)
}

0 comments on commit 6c0263d

Please sign in to comment.