File: req-error.md

package info (click to toggle)
r-cran-httr2 1.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,604 kB
  • sloc: sh: 21; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# failing callback still generates useful body

    Failed to parse error body with method defined in `req_error()`.
    Caused by error:
    ! This is an error!

---

    Code
      req <- request_test("/status/404")
      req <- req %>% req_error(body = ~ resp_body_json(.x)$error)
      req %>% req_perform()
    Condition
      Error in `req_perform()`:
      ! Failed to parse error body with method defined in `req_error()`.
      Caused by error in `resp_body_json()`:
      ! Unexpected content type "text/plain".
      * Expecting type "application/json" or suffix "json".