Skip to content

Errors

Every failure raised by the SDK is an instance of PoliPage::Error (a StandardError subclass). Catch a specific subclass when you want narrow handling, or rescue PoliPage::Error to handle every SDK failure at once. The error’s #code reader is the machine-readable string returned by the API.

Raised before any HTTP call, or in response to a network-layer failure.

Code When
PoliPage::InvalidOptionsError `invalid_options`: the constructor got no API key (`apiKey is required`). Also code PROJECT_REQUIRED_FOR_DOCUMENT (`project is required`) when `project:` is nil or empty. Raised before any HTTP call. Not retryable.
PoliPage::ConnectionError `network_error`: DNS, TCP or TLS failure, or a connection dropped before the whole answer arrived (`Network request failed`). Retryable.
PoliPage::TimeoutError `timeout`: an attempt did not complete within the configured `timeout:` (`Request timed out after <ms>ms`). Retryable.
PoliPage::DownloadError `DOWNLOAD_FAILED`: the presigned-URL download failed (`Failed to download PDF: HTTP <status>`, `Failed to download PDF: network error`, or `Failed to download PDF: timeout` when it outlasted `timeout:`). Never retried, whatever the storage status.
PoliPage::InvalidResponseError `invalid_response`: a 2xx answer whose body is not JSON, usually from a proxy (`Invalid response: HTTP <status> body is not JSON`), with the real 2xx as `status`. Never retried; `to_payload` answers 502.
PoliPage::FileWriteError `io_error`: `render_to_file` could not write the file (`Failed to write PDF: <reason>`), the Ruby error as `cause`. No status, never retried; the target file is left untouched.
PoliPage::InternalError Unexpected response shape from the API (a 2xx JSON value that is not an object).

The transport classifies API responses into one of these subclasses based on HTTP status. The #code reader carries the machine-readable string from the response body.

Code When
PoliPage::ValidationError HTTP 400 — request body or parameters rejected by the API.
PoliPage::AuthenticationError HTTP 401 — missing or invalid API key.
PoliPage::PermissionDeniedError HTTP 403 — key lacks permission for the requested resource.
PoliPage::NotFoundError HTTP 404 — project/template slug or document id does not exist.
PoliPage::GoneError HTTP 410 — document deleted, or a sandbox document over 30 days old.
PoliPage::RateLimitError HTTP 429 — per-key rate limit (retryable) or monthly quota / overage cap reached (not retryable).
PoliPage::APIError Any other 4xx / 5xx the SDK does not map to a more specific class.
Code When
MISSING_API_KEY No API key in the request.
INVALID_API_KEY The API key is malformed, revoked, or belongs to a deleted environment or a disabled or deleted service account.
API_KEY_EXPIRED The API key's expiry has passed.
Code When
ORGANIZATION_PAYMENT_GRACE The organization is in payment grace: read-only, writes are refused.
ORGANIZATION_CANCELLED The organization has been cancelled: read-only until purge.
ORGANIZATION_PURGED The organization has been purged (410).
ORGANIZATION_MIGRATING The organization's storage is being migrated (503). Retryable.
FORBIDDEN Document of another organization, or of another environment than the key's.
PROJECT_OUT_OF_SCOPE The key is restricted to other projects than the one rendered.
ENVIRONMENT_PROTECTED documents.delete in a protected environment without role owner or admin.
THUMBNAILS_NOT_AVAILABLE documents.thumbnails on the Free tier.
Code When
NOT_FOUND Generic not found, e.g. a removed route.
PROJECT_NOT_FOUND No project with this slug in the organization.
PROJECT_NOT_IN_ENVIRONMENT The project was never published in the key's environment, or was removed from it.
TEMPLATE_NOT_FOUND The template is absent from the environment's published copy.
DOCUMENT_NOT_FOUND No stored document matches the supplied id.
DOCUMENT_GONE Deleted document, or sandbox document older than 30 days (410).
Code When
VALIDATION_ERROR Body failed validation: an unknown field, or thumbnail options out of bounds.
MISSING_DATA Request body lacks the required `data` field.
MISSING_TEMPLATE_SLUG Template slug is missing.
PROJECT_REQUIRED_FOR_DOCUMENT render.document was called without `project:`.
TEMPLATE_ERROR The engine rejected the template or its data.
TEMPLATE_UNSAFE The template, a partial or an SVG asset holds an injection attempt; the message names it. Not retryable.
EMPTY_DOCUMENT The render produced zero pages.
ENVIRONMENT_MISMATCH A key caller named another environment. Cannot happen with this SDK.
RENDER_BODY_TOO_LARGE Request body over 2 MB (413).
DOCUMENT_TOO_LARGE The document exceeds an engine cap (413).
Code When
RATE_LIMIT_EXCEEDED Over 120 render requests per 60 s for this key. Retryable.
QUOTA_EXCEEDED Monthly quota reached. Not retryable: it lasts until the monthly reset.
OVERAGE_CAP_EXCEEDED Overage cap reached (paid tiers). Not retryable.
Code When
INTERNAL_ERROR Unexpected server error. Retryable.
STORAGE_ACCESS_DENIED The organization's bring-your-own bucket refuses access (502). Not retryable: it lasts until the bucket role is restored.
PUBLISH_IN_PROGRESS The project is being published into this environment (503, with Retry-After). Retryable.
RENDER_TIMEOUT The engine's time budget expired (504). Retryable.