Skip to content

Commit

Permalink
Enhance ping_edi() to better handle network issues (#154)
Browse files Browse the repository at this point in the history
Improve ping_edi() function to gracefully handle network errors, enhancing
overall system robustness.
  • Loading branch information
clnsmth committed Aug 16, 2024
1 parent b7becac commit a97de62
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -1131,13 +1131,19 @@ parse_delim <- function(x){
# Is the EDI Data Repository accessible?
#
ping_edi <- function() {
r <- httr::RETRY("GET", url = "https://pasta.lternet.edu/package/eml/edi/759") # Warn if EDI is down
if (httr::status_code(r) != 200) {
stop("The EDI Repository is down for regular maintenance (Wednesday 01:00",
" - 03:00 UTC). If you have reached this message outside maintenance",
" hours, then there is an unexpected issue that will be resolved ",
"shortly. Our apologies for the inconvenience. Please try again ",
"later.", call. = FALSE)
r <- tryCatch(
httr::RETRY("GET", url = "https://pasta.lternet.edu/package/eml/edi/759", quiet = TRUE), # Warn if EDI is down
error = function(e) FALSE,
warning = function(w) FALSE
)
if (is.logical(r)) {
stop(
"The EDI Repository is down for regular maintenance (Wednesday 01:00",
" - 03:00 UTC). If you have reached this message outside maintenance",
" hours, then there is an unexpected issue that will be resolved ",
"shortly. Our apologies for the inconvenience. Please try again ",
"later."
)
}
}

Expand Down

0 comments on commit a97de62

Please sign in to comment.