YoukaRequestError, और async tasks के लिए YoukaTaskError जो non-successful state में समाप्त हुई हों। दोनों Error को extend करते हैं और structured fields रखते हैं ताकि आप code, status, और retryability के आधार पर branch कर सकें।
YoukaRequestError
HTTP errors, request validation failures, और malformed responses के लिए throw किया जाता है।
Fields
string
Machine-readable error code, उदाहरण के लिए
INVALID_REQUEST, UNAUTHORIZED,
UPLOAD_FAILED.string
Human-readable विवरण।
number
HTTP status code, यदि उपलब्ध हो।
boolean
true यदि SDK इस error को retry करने लायक मानता है (rate limits, transient
server errors, idempotent replay in progress).unknown
Server द्वारा प्रदान किए गए details, आमतौर पर validation errors के लिए Zod issue list।
Common codes
YoukaTaskError
client.tasks.wait(...), client.projects.wait(...), और client.exports.wait(...) से throw किया जाता है जब underlying task या export failed, cancelled, या timed-out में समाप्त होता है।
Fields
'TASK_FAILED' | 'TASK_CANCELLED' | 'TASK_TIMED_OUT'
Task की terminal status से सीधे map होता है।
string
या तो server द्वारा प्रदान किया गया task error message, या एक generated fallback।
TaskStatus
Terminal task status।
RestTask
Failure के क्षण में पूरा task payload। Logging और
user-facing error messages के लिए उपयोगी।
Retry pattern
retryable को idempotency key के साथ मिलाकर एक सुरक्षित retry loop बनाएं:
Abort and cancellation
किसी request को abort करने पर standardAbortError throw होता है — YoukaRequestError नहीं। इसे explicit रूप से check करें:
आगे क्या
- Tasks — wait helpers और advanced task polling
- Authentication — constructor options और signals
- API errors — raw HTTP में वही codes
