Learn R Programming

fauxpas (version 0.5.2)

Error: Error class

Description

Error class

Arguments

behavior

Behavior of the error. default: auto. See Details

message_template

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.

call.

(logical) indicating if the call should become part of the error message. Default: FALSE

message_template_verbose

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)

muffle

(logical) whether to not respond when status codes in 1xx-3xx series. Default: FALSE

behavior parameter options

  • 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.

Details

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()

See Also

http, Error-Classes

Examples

Run this code
Error$new()
# reset behavior
(z <- Error$new())
z$set_behavior("warning")
z

Run the code above in your browser using DataLab