Skip to content

Commit

Permalink
Merge pull request #148 from POLAR-fhiR/146.2-fhir_search-crashes-whe…
Browse files Browse the repository at this point in the history
…n-server-is-down

turn errors into warnings for check_response
  • Loading branch information
palmjulia authored Jan 2, 2025
2 parents f8acf2c + 116e62e commit 16cac88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions R/download_resources.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
#' @param max_attempts `r lifecycle::badge("deprecated")` The number of maximal attempts is now determined by the length of `delay_between_attempts`
#' @param delay_between_attempts A numeric vector specifying the delay in seconds between attempts of reaching the server
#' that `fhir_search()` will make. The length of this vector determines the number of attempts that will be made when the server can't be reached
#' before stopping with an error. Defaults to `c(1,3,9,27,81)`.
#' before stopping with an error. Defaults to `c(1,3,9,27,81)`. If you want the function to stop immediately after the first error when trying to
#' reach the server, set this argument to `1`.
#' @param log_errors Either `NULL` or a character vector of length one indicating the name of a file in which to save the http errors.
#' `NULL` means no error logging. When a file name is provided, the errors are saved in the specified file. Defaults to `NULL`.
#' Regardless of the value of `log_errors` the most recent http error message within the current R session is saved internally and can
Expand Down Expand Up @@ -1203,13 +1204,13 @@ check_response <- function(response, log_errors, append = FALSE) {
}
if(400 <= code && code < 500) {
if(!is.null(log_errors)) {
stop(
warning(
"Your request generated a client error, HTTP code ",
code,
". For more information see the generated error file."
)
} else {
stop(
warning(
"Your request generated a client error, HTTP code ",
code,
". To print more detailed error information, run fhir_recent_http_error() or set argument log_errors to a filename and rerun you request."
Expand All @@ -1218,13 +1219,13 @@ check_response <- function(response, log_errors, append = FALSE) {
}
if(500 <= code && code < 600) {
if(!is.null(log_errors)) {
stop(
warning(
"Your request generated a server error, HTTP code ",
code,
". For more information see the generated error file."
)
} else {
stop(
warning(
"Your request generated a server error, HTTP code ",
code,
". To print more detailed error information, run fhir_recent_http_error() or set argument log_errors to a filename and rerun you request."
Expand Down
3 changes: 2 additions & 1 deletion man/fhir_search.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 16cac88

Please sign in to comment.