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.
statusThe HTTP status code.
codeThe machine-readable error code. Codes mirror the REST error model; the SDK-only SDK_POLL_TIMEOUT is the one addition.
messageA human-readable description of what went wrong.
detailsOptional structured context attached to the error, or null.
requestIdThe x-lirovo-request-id for the failed request. Quote it to support to find the request in the logs.
retryAfterMsSuggested wait before retrying, in milliseconds, when the API returned a retry-after hint.
docUrlOptional 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.
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.