Error Codes
The SDKs validate input parameters locally and intercept raw HTTP network responses to format clean, diagnostic error structures.
1. Catching SDK Exceptions
Compare how exceptions are structured and caught:
typescript
try { await sdk.collection("users").insert({ username: "johndoe" });} catch (error: any) { // Catching standard JavaScript Error object console.error("Error Name:", error.name); console.error("Error Message:", error.message); // Example Message: "[ThinkingDifferently SDK Error] 401: Unauthorized access"}2. SDK Error Classifications
Exceptions generally fall into two categories:
- Network Errors: Occur when the server cannot be reached due to connection drops or DNS failures.[ThinkingDifferently Network Error] <Connection details...>
- Structured API Errors: Returned when the database processes requests but rejects them due to credentials or parameters.[ThinkingDifferently SDK Error] <Status Code>: <Error Message Details...>
3. Common API Error Codes
| HTTP Code | Error Code | Root Cause | Corrective Action |
|---|---|---|---|
| 401 | UNAUTHORIZED | API Key is invalid or expired. | Verify `apiKey` or `securityKey` parameters. |
| 404 | PROJECT_NOT_FOUND | The requested Project ID was not found. | Check dashboard project settings identifier. |
| 400 | INVALID_PAYLOAD | Missing required database parameters or malformed data. | Confirm JSON fields or document sizes. |
| 429 | RATE_LIMIT_EXCEEDED | Project has hit its concurrent API usage quota limit. | Implement request caching or backoff retries. |