SDK

Errors

Every non-2xx response is thrown as a LirovoApiError. It carries the parsed Lirovo error envelope, and its codes mirror the REST error model.

LirovoApiError#

LirovoApiError extends Error (so message is the human-readable description) and adds the parsed envelope fields below.

status
number

The HTTP status code.

code
LirovoErrorCode

The machine-readable error code. Codes mirror the REST error model; the SDK-only SDK_POLL_TIMEOUT is the one addition.

message
string

A human-readable description of what went wrong.

details
unknown

Optional structured context attached to the error, or null.

requestId
string | undefined

The x-lirovo-request-id for the failed request. Quote it to support to find the request in the logs.

retryAfterMs
number | null

Suggested wait before retrying, in milliseconds, when the API returned a retry-after hint.

docUrl
string | undefined

Optional link to documentation for the error, when the API supplies one.

Handling errors#

Catch LirovoApiError and branch on code. The SDK-only SDK_POLL_TIMEOUT means the client gave up polling (the job may still be running), distinct from the server-side UPSTREAM_TIMEOUT.

ts
import { Lirovo, LirovoApiError } from "@lirovo/sdk";

try {
  const result = await lirovo.jobs.waitForResult(job.id);
} catch (err) {
  if (err instanceof LirovoApiError) {
    console.error(err.code, err.status, err.message);
    if (err.code === "SDK_POLL_TIMEOUT") {
      // still running; poll again later or raise the timeout
    }
  } else {
    throw err;
  }
}

Error codes#

The error codes mirror the REST error model. See the API error model for the full envelope contract and the complete list of codes.