ndi-sdk extends NdiError. Check a specific class when
your application can recover from that failure, or check NdiError at the
outer SDK boundary.
Error hierarchy
Handle common failures
HTTP status errors
NdiStatusError means the server returned a non-success HTTP response. It
exposes:
Handle error codes when behavior differs within one HTTP status:
ErrorCode is open-ended. Unknown codes remain usable strings instead of
causing response parsing to fail.
unsupported_file_type is an InvalidRequestError with status 422. It is
returned synchronously by an upload boundary or document-operation start, so
there is no failed job to poll. A rejected workspace upload also creates no
file. Check err.code === ErrorCode.UNSUPPORTED_FILE_TYPE; do not retry the
same request or maintain a separate client-side format allowlist.
Job errors are different
An HTTP request can succeed while the asynchronous job later fails.JobFailedError therefore contains the terminal job, including
job.error.code, job.error.message, and any job-specific detail.
JobTimeoutError only means the local jobs.wait budget expired. The job
continues server-side and can be read again with client.jobs.get(jobId).
Connection and HTTP timeouts
NdiConnectionError means no response was produced because of DNS, TLS,
connection, or transport failure. NdiTimeoutError is its timeout-specific
subclass.
The client timeout defaults to 60 seconds per HTTP request:
client.jobs.wait(jobId, { timeout: 600 }), which sets the total polling
budget.
Automatic retries
The SDK retries safe requests after connection failures, HTTP429, and
5xx responses. The default retry policy makes at most three attempts with
exponential backoff and full jitter. The defaults are initial_backoff: 0.5
seconds and max_backoff: 8 seconds. A valid Retry-After response header
takes precedence.
Idempotency-Key. State conflicts (409) and invalid requests are not
retried. Streaming jobs.events connections are not retried automatically;
reconnect with last_event_id when needed.
Best practices
Check specific error classes
Recover from known conditions such as rate limits or missing resources,
then rethrow unexpected values.
Log the request ID
Include
request_id, status_code, and code in logs without recording
API keys or document contents.Distinguish HTTP and job failure
A successful submission can still produce a failed job. Handle both
NdiStatusError and JobFailedError.Preserve idempotency
Let the SDK mint keys, or reuse your explicit key when replaying the same
job-creating request.