UnhandledHTTPRequestError | R Documentation |
Handle http request errors
vcr_last_error()
How this error class is used:
If record="once"
we trigger this.
Users can use vcr in the context of both use_cassette()
and insert_cassette()
For the former, all requests go through the call_block But for the latter, requests go through webmockr.
Where is one place where we can put UnhandledHTTPRequestError that will handle both use_cassette and insert_cassette?
record=once
AND there's a new request that doesn't match
the one in the cassette on disk
in webmockr: if no stub found and there are recorded interactions on the cassette, and record = once, then error with UnhandledHTTPRequestError
but if record != once, then allow it, unless record == none
others?
request
a Request object
cassette
a cassette name
new()
Create a new UnhandledHTTPRequestError
object
UnhandledHTTPRequestError$new(request)
request
(Request) a Request object
A new UnhandledHTTPRequestError
object
run()
Run unhandled request handling
UnhandledHTTPRequestError$run()
various
construct_message()
Construct and execute stop message for why request failed
UnhandledHTTPRequestError$construct_message()
a stop message
request_description()
construct request description
UnhandledHTTPRequestError$request_description()
character
current_matchers()
get current request matchers
UnhandledHTTPRequestError$current_matchers()
character
match_request_on_headers()
are headers included in current matchers?
UnhandledHTTPRequestError$match_request_on_headers()
logical
match_request_on_body()
is body includled in current matchers?
UnhandledHTTPRequestError$match_request_on_body()
logical
formatted_headers()
get request headers
UnhandledHTTPRequestError$formatted_headers()
character
cassettes_description()
construct description of current or lack thereof cassettes
UnhandledHTTPRequestError$cassettes_description()
character
cassettes_list()
cassette details
UnhandledHTTPRequestError$cassettes_list()
character
get_help()
get help message for non-verbose error
UnhandledHTTPRequestError$get_help()
character
formatted_suggestions()
make suggestions for what to do
UnhandledHTTPRequestError$formatted_suggestions()
character
format_bullet_point()
add bullet point to beginning of a line
UnhandledHTTPRequestError$format_bullet_point(lines, index)
lines
(character) vector of strings
index
(integer) a number
character
format_foot_note()
make a foot note
UnhandledHTTPRequestError$format_foot_note(url, index)
url
(character) a url
index
(integer) a number
character
suggestion_for()
get a suggestion by key
UnhandledHTTPRequestError$suggestion_for(key)
key
(character) a character string
character
suggestions()
get all suggestions
UnhandledHTTPRequestError$suggestions()
list
no_cassette_suggestions()
get all no cassette suggestions
UnhandledHTTPRequestError$no_cassette_suggestions()
list
record_mode_suggestion()
get the appropriate record mode suggestion
UnhandledHTTPRequestError$record_mode_suggestion()
character
has_used_interaction_matching()
are there any used interactions
UnhandledHTTPRequestError$has_used_interaction_matching()
logical
match_requests_on_suggestion()
match requests on suggestion
UnhandledHTTPRequestError$match_requests_on_suggestion()
list
clone()
The objects of this class are cloneable with this method.
UnhandledHTTPRequestError$clone(deep = FALSE)
deep
Whether to make a deep clone.
## Not run:
vcr_configure(dir = tempdir())
cassettes()
insert_cassette("turtle")
request <- Request$new("post", 'https://hb.opencpu.org/post?a=5',
"", list(foo = "bar"))
err <- UnhandledHTTPRequestError$new(request)
err$request_description()
err$current_matchers()
err$match_request_on_headers()
err$match_request_on_body()
err$formatted_headers()
cat(err$formatted_headers(), "\n")
cat(err$cassettes_description(), "\n")
cat(err$cassettes_list(), "\n")
err$formatted_suggestions()
cat(err$format_bullet_point('foo bar', 1), "\n")
err$suggestion_for("use_new_episodes")
err$suggestions()
err$no_cassette_suggestions()
err$record_mode_suggestion()
err$has_used_interaction_matching()
err$match_requests_on_suggestion()
# err$construct_message()
# cleanup
eject_cassette("turtle")
unlink(tempdir())
## End(Not run)
## Not run:
# vcr_last_error()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.