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
Machine-readable error code, उदाहरण के लिए
INVALID_REQUEST, UNAUTHORIZED,
UPLOAD_FAILED.Human-readable विवरण।
HTTP status code, यदि उपलब्ध हो।
true यदि SDK इस error को retry करने लायक मानता है (rate limits, transient
server errors, idempotent replay in progress).Server द्वारा प्रदान किए गए details, आमतौर पर validation errors के लिए Zod issue list।
Common codes
| Code | कारण | Retryable? |
|---|---|---|
INVALID_REQUEST | भेजने से पहले request body schema validation में fail हुई। | No |
UNAUTHORIZED | API key missing या invalid। | No |
NOT_FOUND | Resource मौजूद नहीं है या आपके पास access नहीं है। | No |
CONFLICT | Version conflict (HTTP 409)। | Yes |
TOO_MANY_REQUESTS | Rate limit hit (HTTP 429)। | Yes |
INTERNAL_SERVER_ERROR | Transient server failure (HTTP 500)। | Yes |
IDEMPOTENT_REPLAY_IN_PROGRESS | Original request उसी idempotency key के तहत अभी भी चल रही है (HTTP 202)। | Yes |
INVALID_RESPONSE | Server ने ऐसा body लौटाया जो expected schema से match नहीं हुआ। | No |
UPLOAD_FAILED | Signed URL upload ने non-2xx लौटाया। | Depends on status |
YoukaTaskError
client.tasks.wait(...), client.projects.wait(...), और client.exports.wait(...) से throw किया जाता है जब underlying task या export failed, cancelled, या timed-out में समाप्त होता है।
Fields
Task की terminal status से सीधे map होता है।
या तो server द्वारा प्रदान किया गया task error message, या एक generated fallback।
Terminal task status।
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
