sc_last_error: Error handling for the STATcube REST API

View source: R/error.R

sc_last_errorR Documentation

Error handling for the STATcube REST API

Description

In case API requests are unsuccessful, STATcubeR will throw errors to summarize the httr error type and its meaning. Requests are considered unsuccessful if one of the following applies

  • The response returns TRUE for httr::http_error().

  • The response is not of type "application/json"

In some cases it is useful to get direct access to a faulty response object. For that purpose, it is possible to use sc_last_error() which will provide the httr response object for the last unsuccessful request.

Usage

sc_last_error()

sc_last_error_parsed()

Value

The return value from httr::GET() or httr::POST().

Functions

  • sc_last_error_parsed(): returns the last error as a list containing the response content and the response status

Examples


try(sc_table_saved("invalid_id"))
last_error <- sc_last_error()
httr::content(last_error)
str(sc_last_error_parsed())


STATcubeR documentation built on April 3, 2025, 7:31 p.m.