-
Notifications
You must be signed in to change notification settings - Fork 80
Description
I'm performing a series of requests with req_perform_sequential(). (My use case: I'm a Qualtrics administrator at my univ, using their API to retrieve information about users in our Qualtrics license. I love that I can use lapply() with req_url_query() to construct all the requests so easily.)
I set on_error = 'continue' so that if I mis-type a user ID (or someone doesn't exist in the Qualtrics system), it continues with the rest of the vector of user IDs I provided -- having one response return an error isn't fatal, it's something I expect to happen from time to time, so I need a warning but not an error.
I'm able to wrap up the successful responses into a tibble using:
resps |>
httr2::resps_successes() |>
httr2::resps_data(
\(resp) httr2::resp_body_json(resp) |>
purrr::pluck('result') |>
dplyr::bind_rows()
)
but the tibble only includes the calls that were successful. If I were to remove httr2::resps_successes(), it would error, because resp_body_json() can't be called on an <httr2_http_404> object.
Ideally, after performing the requests, I'd like to be able to call something like
resps |>
resps_failures() |>
rlang::warn('Failed to retrieve user data for {user_id}')
or to be able to set req_error() to throw a warning instead of an error for the requests that failed. (May be related to [#343]?)
Another possibility might be to add a NA = TRUE argument to resps_data() or resp_body_json() so the failures return NA, though I can see where that might create more problems than it solves.