Handle http request errors
Details
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?
Error situations where this is invoked
Public fields
request
a Request object
cassette
a cassette name
Methods
Method new()
Create a new UnhandledHTTPRequestError
object
Returns
A new UnhandledHTTPRequestError
object
Method run()
Run unhandled request handling
Usage
UnhandledHTTPRequestError$run()
Method construct_message()
Construct and execute stop message for why request failed
Usage
UnhandledHTTPRequestError$construct_message()
Method request_description()
construct request description
Usage
UnhandledHTTPRequestError$request_description()
Method current_matchers()
get current request matchers
Usage
UnhandledHTTPRequestError$current_matchers()
are headers included in current matchers?
Usage
UnhandledHTTPRequestError$match_request_on_headers()
Method match_request_on_body()
is body includled in current matchers?
Usage
UnhandledHTTPRequestError$match_request_on_body()
get request headers
Usage
UnhandledHTTPRequestError$formatted_headers()
Method cassettes_description()
construct description of current or lack thereof cassettes
Usage
UnhandledHTTPRequestError$cassettes_description()
Method cassettes_list()
cassette details
Usage
UnhandledHTTPRequestError$cassettes_list()
Method get_help()
get help message for non-verbose error
Usage
UnhandledHTTPRequestError$get_help()
make suggestions for what to do
Usage
UnhandledHTTPRequestError$formatted_suggestions()
add bullet point to beginning of a line
Usage
UnhandledHTTPRequestError$format_bullet_point(lines, index)
Arguments
lines
(character) vector of strings
index
(integer) a number
make a foot note
Usage
UnhandledHTTPRequestError$format_foot_note(url, index)
Arguments
url
(character) a url
index
(integer) a number
Method suggestion_for()
get a suggestion by key
Usage
UnhandledHTTPRequestError$suggestion_for(key)
Arguments
key
(character) a character string
Method suggestions()
get all suggestions
Usage
UnhandledHTTPRequestError$suggestions()
Method no_cassette_suggestions()
get all no cassette suggestions
Usage
UnhandledHTTPRequestError$no_cassette_suggestions()
Method record_mode_suggestion()
get the appropriate record mode suggestion
Usage
UnhandledHTTPRequestError$record_mode_suggestion()
Method has_used_interaction_matching()
are there any used interactions
Usage
UnhandledHTTPRequestError$has_used_interaction_matching()
Method match_requests_on_suggestion()
match requests on suggestion
Usage
UnhandledHTTPRequestError$match_requests_on_suggestion()
Method clone()
The objects of this class are cloneable with this method.
Usage
UnhandledHTTPRequestError$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
if (FALSE) { # \dontrun{
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())
} # }
if (FALSE) { # \dontrun{
# vcr_last_error()
} # }