Error class
Behavior of the error. default: auto. See Details
A message template. optional. use whisker
templating. names to use are: reason and status. use in template
like {{reason}}
and {{status}}
. Note that
{{message}}
that is used in message_template_verbose
will be ignored here.
(logical) indicating if the call should become part
of the error message. Default: FALSE
A verbose message template. optional.
use whisker templating. names to use are: reason, status, message.
use in template like {{reason}}
, {{status}}
, and
{{message}}
. Note that this is ignored here, but is
used in the HTTP*
methods (e.g. HTTPBadRequest
)
(logical) whether to not respond when status codes
in 1xx-3xx series. Default: FALSE
Methods
do(response, mssg)
Execute condition, whether it be message, warning, or error.
response: is any response from crul, curl, or httr
Execute condition, whether it be message, warning, error, or your
own custom function. This method uses message_template_verbose
,
and uses it's default value.
mssg: character string message to include in call. ignored if
template does not have a message
entry
set_behavior(behavior)
Set behavior, same as setting behavior on initializing with $new()
stop - use stop
warning - use warning
message - use message
auto - toggle between stop
and message
depending
on the HTTP status code series. Defaults will be:
1xx: message
2xx: message
3xx: message
4xx: stop
5xx: stop
Of course, you can always override the defaults.
Error$new()
#> <HTTP Error>
#> behavior: stop
#> message_template: {{reason}} (HTTP {{status}})
#> message_template_verbose: {{reason}} (HTTP {{status}}).\n - {{message}}
# reset behavior
(z <- Error$new())
#> <HTTP Error>
#> behavior: stop
#> message_template: {{reason}} (HTTP {{status}})
#> message_template_verbose: {{reason}} (HTTP {{status}}).\n - {{message}}
z$set_behavior("warning")
z
#> <HTTP Error>
#> behavior: warning
#> message_template: {{reason}} (HTTP {{status}})
#> message_template_verbose: {{reason}} (HTTP {{status}}).\n - {{message}}