diff --git a/paws.common/NEWS.md b/paws.common/NEWS.md index 80f79c20a..d8363bd31 100644 --- a/paws.common/NEWS.md +++ b/paws.common/NEWS.md @@ -21,7 +21,7 @@ resp <- client$get_object( Key = "", IfNoneMatch = "" ) -#> Error: SerializationError (HTTP 304). An error occurred (304) when calling the GetObject operation: Not Modified +#> Error: SerializationError (HTTP 304). An error occurred when calling the GetObject operation: Not Modified ``` * use s3 head_bucket operation as final resort when redirecting aws s3 call. diff --git a/paws.common/R/error.R b/paws.common/R/error.R index c8892f344..e5b310c86 100644 --- a/paws.common/R/error.R +++ b/paws.common/R/error.R @@ -8,7 +8,7 @@ Error <- struct( error_response = list() ) -ERROR_MSG_TEMPLATE <- "An error occurred (%s) when calling the %s operation: %s" +ERROR_MSG_TEMPLATE <- "An error occurred when calling the %s operation%s: %s" serialization_error <- function(request) { error_message <- http_statuses[[ @@ -18,14 +18,23 @@ serialization_error <- function(request) { "SerializationError", sprintf( ERROR_MSG_TEMPLATE, - request$http_response$status_code, request$operation$name, + get_retry_info(request$retry_count), error_message ), request$http_response$status_code ) } +get_retry_info <- function(retry_count){ + if (retry_count) { + retry_msg <- sprintf(" (reached max retries: %d)", retry_count) + } else { + retry_msg <- "" + } + return(retry_msg) +} + #' Generate a classed http error #' #' This function generates S3 error objects which are passed to diff --git a/paws.common/R/retry.R b/paws.common/R/retry.R index 997b85a66..0f708c727 100644 --- a/paws.common/R/retry.R +++ b/paws.common/R/retry.R @@ -50,6 +50,7 @@ standard_retry_handler <- function(request) { for (i in seq.int(2, exit_retries)) { tryCatch( { + request$retry_count <- i - 1 request <- sign(request) if (!is.null(request[["error"]])) { stop(aws_error(request[["error"]])) @@ -57,7 +58,6 @@ standard_retry_handler <- function(request) { request <- send(request) request <- unmarshal_meta(request) request <- validate_response(request) - if (!is.null(request[["error"]])) { request <- unmarshal_error(request) stop(aws_error(request[["error"]]))