'Loop through error when checking http status code

I have a list of websites and my goal is to check each of their status codes. I have the following, where urls is a list of websites.

for (i in seq_along(urls)) {
  r <- GET(test[i])
  s <- status_code(r)
}

When I run the for loop, I get the message: Error in curl::curl_fetch_memory(url, handle = handle) : schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The target principal name is incorrect.

I am thinking of handling this with tryCatch but I am not sure of the syntax or whether to place the entire for loop in tryCatch.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source