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 CodeError CodeRoot CauseCorrective Action
401UNAUTHORIZEDAPI Key is invalid or expired.Verify `apiKey` or `securityKey` parameters.
404PROJECT_NOT_FOUNDThe requested Project ID was not found.Check dashboard project settings identifier.
400INVALID_PAYLOADMissing required database parameters or malformed data.Confirm JSON fields or document sizes.
429RATE_LIMIT_EXCEEDEDProject has hit its concurrent API usage quota limit.Implement request caching or backoff retries.