Error Handling

Learn how to handle errors and edge cases in the Duro API.

Error Types

The API returns different types of errors:

  • Validation errors

  • Authentication errors

  • Authorization errors

  • Rate limiting errors

  • Server errors

Error Format

{
  "errors": [
    {
      "message": "Not authorized to access Component",
      "path": ["component"],
      "extensions": {
        "code": "FORBIDDEN",
        "classification": "AuthorizationError"
      }
    }
  ]
}

Common Error Scenarios

# Rate Limiting Error
{
  "errors": [
    {
      "message": "Rate limit exceeded",
      "extensions": {
        "code": "RATE_LIMITED",
        "retryAfter": 60
      }
    }
  ]
}

Best Practices

  • Implement proper error handling

  • Add retry logic for rate limits

  • Log errors for debugging

  • Handle network timeouts

  • Provide user-friendly error messages

Error Recovery

async function queryWithRetry(query: string, maxRetries = 3) {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      return await executeQuery(query);
    } catch (error) {
      if (!isRetryableError(error) || attempt === maxRetries) {
        throw error;
      }
      await delay(exponentialBackoff(attempt));
    }
  }
}

Next Steps

Join our Developer Community for support and discussions.

Last updated