Errors raised by legihelpR API functions
legihelpR-errors.RdEvery API function stops with a classed condition when a request fails, so
callers can tell failures that are worth trying again later from ones that
will fail again unchanged. All of them inherit from legihelpR_error
and can be caught with tryCatch().
Temporary failures are retried automatically, up to 3 attempts per request,
before an error is raised: HTTP 429 and 503 responses, API messages that
plainly report rate limiting, and, for read-only functions, HTTP 502 and
504 responses and network failures. Waits honor LegiScan's
Retry-After header and otherwise back off exponentially. When the
server asks for a longer wait than the legihelpR.max_retry_wait
option allows (60 seconds by default), legihelpR stops instead of waiting;
the requested wait is in the error's retry_after field. Other
failures stop immediately.
setMonitor() changes the monitor list of the account, so it is only
retried after responses that say the request was not handled (HTTP 429 and
503, or a rate limit message). After a network failure or gateway error the
change may or may not have been applied; check getMonitorList()
before repeating it.
LegiScan does not publish its error messages, so classes that depend on
the message are matched conservatively. Unrecognized API errors keep the
generic legihelpR_api_error class.
Condition classes
legihelpR_rate_limitedToo many requests. Temporary: wait and try again, or increase
options(legihelpR.request_interval).legihelpR_unavailableHTTP 502, 503 or 504. Temporary.
legihelpR_network_errorLegiScan could not be reached. Usually temporary.
legihelpR_quota_exceededThe key's query allowance is used up. Retrying will not help until it resets.
legihelpR_invalid_keyLegiScan does not recognize the API key.
legihelpR_access_deniedThe account is not allowed to make the request, for example a disabled key, missing subscription, or HTTP 401 or 403.
legihelpR_invalid_requestLegiScan rejected the request parameters, for example an unknown id or stale dataset access key.
legihelpR_invalid_responseThe response could not be read, for example a web page instead of JSON, or a download that is not a ZIP archive.
legihelpR_api_errorAdded to every error LegiScan reported with
status = "ERROR", and the only class for unrecognized ones.legihelpR_http_errorAdded to every error from an HTTP 4xx or 5xx response.