Skip to main content
The SDK surfaces two error classes: YoukaRequestError for HTTP and validation failures, and YoukaTaskError for async tasks that ended in a non-successful state. Both extend Error and carry structured fields so you can branch on code, status, and retryability.

YoukaRequestError

Thrown for HTTP errors, request validation failures, and malformed responses.

Fields

code
string
Machine-readable error code, for example INVALID_REQUEST, UNAUTHORIZED, UPLOAD_FAILED.
message
string
Human-readable description.
status
number
HTTP status code, if available.
retryable
boolean
true if the SDK considers the error worth retrying (rate limits, transient server errors, idempotent replay in progress).
details
unknown
Server-provided details, typically a Zod issue list for validation errors.

Common codes

YoukaTaskError

Thrown from client.tasks.wait(...), client.projects.wait(...), and client.exports.wait(...) when the underlying task or export ends in failed, cancelled, or timed-out.

Fields

code
'TASK_FAILED' | 'TASK_CANCELLED' | 'TASK_TIMED_OUT'
Maps directly to the task’s terminal status.
message
string
Either the server-provided task error message or a generated fallback.
status
TaskStatus
The terminal task status.
task
RestTask
The full task payload at the moment of failure. Useful for logging and user-facing error messages.

Retry pattern

Combine retryable with an idempotency key to build a safe retry loop:
Always reuse the same idempotency key across retries. Otherwise the server treats the retry as a new request and you may end up with duplicates.

Abort and cancellation

Aborting a request throws a standard AbortError — not a YoukaRequestError. Check for it explicitly:

What’s next