File: handle_errors.R

package info (click to toggle)
r-cran-rtweet 1.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 18,224 kB
  • sloc: sh: 13; makefile: 2
file content (13 lines) | stat: -rw-r--r-- 269 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
handle_errors <- function(response) {
  if (!httr::status_code(response)) {
    return(response)
  }

  obj <- httr::content(response)
  if (has_name_(obj, "errors")) {
    l <- lapply(obj$errors, list2DF)
    errors <- do.call(rbind, l)
    return(errors)
  }
  obj
}