@@ -85,21 +85,34 @@ const { data } = await roxy.crystals.searchCrystals({
8585
8686### Error handling
8787
88+ All errors return ` { error: string, code: string } ` . The ` error ` field is human-readable (may change wording). The ` code ` field is machine-readable (stable, safe to switch on).
89+
8890``` typescript
8991const { data, error, response } = await roxy .astrology .getDailyHoroscope ({
9092 path: { sign: ' aries' },
9193});
9294
9395if (error ) {
94- // error is { error: string } on 4xx/5xx
95- console .error (' Status :' , response ?. status , ' Error :' , error );
96+ // error is { error: string, code: string } on 4xx/5xx
97+ console .error (' Code :' , error . code , ' Message :' , error . error );
9698 return ;
9799}
98100// data is fully typed after error check
99101console .log (data .sign , data .overview );
100102```
101103
102- Common error codes: ` 401 ` invalid/missing API key, ` 403 ` subscription expired or limit reached, ` 429 ` rate limited, ` 404 ` resource not found.
104+ Error codes:
105+
106+ | Status | Code | When |
107+ | --------| ------| ------|
108+ | 400 | ` validation_error ` | Missing or invalid parameters |
109+ | 401 | ` api_key_required ` | No API key provided |
110+ | 401 | ` invalid_api_key ` | Key format invalid or tampered |
111+ | 401 | ` subscription_not_found ` | Key references non-existent subscription |
112+ | 401 | ` subscription_inactive ` | Subscription cancelled, expired, or suspended |
113+ | 404 | ` not_found ` | Resource not found |
114+ | 429 | ` rate_limit_exceeded ` | Monthly quota reached |
115+ | 500 | ` internal_error ` | Server error |
103116
104117## Common tasks
105118
@@ -142,6 +155,7 @@ const city = cities[0];
142155- ** Date format is ` YYYY-MM-DD ` , time is ` HH:MM:SS ` .** Both are strings. Timezone is optional (IANA format like ` America/New_York ` ).
143156- ** All list endpoints may return paginated objects** (e.g. ` { items: [...], total: N } ` ) rather than raw arrays. Check the type.
144157- ** ` data ` and ` error ` are mutually exclusive.** If ` error ` is set, ` data ` is ` undefined ` and vice versa.
158+ - ** Errors have ` error ` (message) and ` code ` (machine-readable).** Switch on ` code ` , not ` error ` — the message may change wording.
145159
146160## Links
147161
0 commit comments