RoyalTS
RoyalTS

Reputation: 10203

httr::GET() can't be handled purrr::safely()?

This is probably a fundamental misunderstanding on my part, but I thought purrr::safely() captured all errors and never failed. Yet:

> purrr::safely(httr::GET('http://revolution-news.com/'))
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Couldn't resolve host name

Upvotes: 0

Views: 173

Answers (1)

MrFlick
MrFlick

Reputation: 206167

safely is a function wrapper, not a function call wrapper. Use

purrr::safely(httr::GET)('http://revolution-news.com/')

Notice how it wraps the function GET(), not the call to get. You could break that apart to

safe_GET <- purrr::safely(httr::GET)
safe_GET('http://revolution-news.com/')

Upvotes: 4

Related Questions