Skip to content
This repository has been archived by the owner on Oct 28, 2019. It is now read-only.

Commit

Permalink
Fail immediately in consume() if error code is 400. #57
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Jul 13, 2016
1 parent da00578 commit 3b8b47f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/consume.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ callAPI <- function(apiKey, requestUrl, keyvalues, globalParam,
postfields = body
)
)
r <- try_fetch(requestUrl, h, delay = retryDelay, .retry = .retry)
r <- try_fetch(requestUrl, h, no_retry_on = 400, delay = retryDelay, .retry = .retry)
result <- fromJSON(rawToChar(r$content))
if(r$status_code >= 400) {
stop(paste(capture.output(result), collapse="\n"))
Expand Down
10 changes: 8 additions & 2 deletions R/fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ validate_response <- function(r){
# @return the result of curl_fetch_memory(uri, handle)
#
try_fetch <- function(uri, handle,
retry_on = c(400, 401, 440, 503, 504, 509),
retry_on = c(400, 401, 440, 503, 504, 509),
no_retry_on,
.retry = 6,
delay = 1, exponent = 2,
no_message_threshold = 1)
{
r = curl_fetch_memory(uri, handle)
# if(r$status_code == 400) validate_response(r)
# if(r$status_code == 400){
# validate_response(r)
# }
if(!missing(no_retry_on) && !is.null(no_retry_on)){
retry_on <- setdiff(retry_on, no_retry_on)
}
if(!(r$status_code %in% retry_on)) {
validate_response(r)
return(r)
Expand Down

0 comments on commit 3b8b47f

Please sign in to comment.