-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
When a custom error is set with an HTTP code of less than 400 and caching is enabled, the error does not seem to be rethrown.
library(httr2)
request("https://jsonplaceholder.typicode.com/users/1") |>
req_cache(tempdir(), debug = TRUE) |>
req_error(is_error = \(resp) TRUE) |>
req_perform()
#> Pruning cache
#> Saving response to cache "24d35aa431d94a6f148086d4e13301a9"
#> Error in `req_perform()`:
#> ! HTTP 200 OK.
request("https://jsonplaceholder.typicode.com/users/1") |>
req_cache(tempdir(), debug = TRUE) |>
req_error(is_error = \(resp) TRUE) |>
req_perform()
#> Found url in cache "24d35aa431d94a6f148086d4e13301a9"
#> Cached value is fresh; using response from cache
#> <httr2_response>
#> GET https://jsonplaceholder.typicode.com/users/1
#> Status: 200 OK
#> Content-Type: application/json
#> Body: In memory (509 bytes)Created on 2025-10-15 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels