View source: R/check_for_failed_request.R
check_for_failed_request | R Documentation |
This function checks the response body from an API request to determine if the request failed. If the request contains an error message, the function will raise an error with a detailed message including the message ID and value.
check_for_failed_request(body)
body |
The response body from the API request, typically in JSON format, which may contain an error message if the request failed. |
This function inspects the first element of the response body to check for
an error message. If a message is found, the function retrieves the id
, key
, and
value
fields from the error message and constructs an error using cli::cli_abort()
.
The function is intended to ensure failed API requests are handled gracefully.
This function does not return a value. If the request contains an error message, it raises an error and halts execution.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.