Skip to content

Commit

Permalink
catch errors in check_urls; fixes #38
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed May 15, 2024
1 parent 3e7d167 commit 1cc474d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: allcontributors
Title: Acknowledge all Contributors to a Project
Version: 0.1.1.005
Version: 0.1.1.006
Authors@R:
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"))
Description: Acknowledge all contributors to a project via a single
Expand Down
29 changes: 27 additions & 2 deletions R/urlcheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,32 @@ check_github_urls <- function (ctbs, quiet = FALSE) {
pool = pool
)
}
curl::multi_run (pool = pool)
chk <- tryCatch (
curl::multi_run (pool = pool),
error = function (e) NULL
)
# Retry request on fail:
if (is.null (chk)) {
n_retries <- 3L
n_actual <- 1L
while (n_actual <= n_retries && is.null (chk)) {
Sys.sleep (1)
chk <- tryCatch (
curl::multi_run (pool = pool),
error = function (e) NULL
)
n_actual <- n_actual + 1
}
}
if (is.null (chk)) {
if (!quiet) {
message (
"\r", cli::col_green (cli::symbol$cross),
" Checking GitHub URLs failed; contributors will be added regardless"
)
}
return (ctbs)
}

if (!quiet) {
message (
Expand All @@ -72,7 +97,7 @@ check_github_urls <- function (ctbs, quiet = FALSE) {
for (i in seq_along (out)) {
if (inherits (hs [[i]], "error")) {
out [[i]] <- -1L
} else {
} else if ("status_code" %in% names (hs [[i]])) {
out [[i]] <- hs [[i]]$status_code
}
}
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"codeRepository": "https://github.com/ropenscilabs/allcontributors",
"issueTracker": "https://github.com/ropenscilabs/allcontributors/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.1.1.005",
"version": "0.1.1.006",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit 1cc474d

Please sign in to comment.