Skip to Content
APIError Handling

Error Handling

Understanding and handling errors from the HyperDynamic Controller API.

Error Response Format

All errors follow a consistent format:

{ "error": { "code": "INVALID_REQUEST", "message": "The request body is invalid", "details": {} } }

HTTP Status Codes

CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Resource doesn’t exist
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Codes

Authentication Errors

  • INVALID_API_KEY - The API key is invalid
  • EXPIRED_API_KEY - The API key has expired
  • INSUFFICIENT_PERMISSIONS - The API key lacks required permissions

Validation Errors

  • INVALID_REQUEST - The request format is invalid
  • MISSING_FIELD - A required field is missing
  • INVALID_FIELD - A field value is invalid

Resource Errors

  • NOT_FOUND - The requested resource was not found
  • ALREADY_EXISTS - A resource with this identifier already exists

Handling Errors

try { const response = await fetch('/api/controllers', { headers: { 'Authorization': `Bearer ${apiKey}` } }) if (!response.ok) { const error = await response.json() console.error(`Error: ${error.error.code} - ${error.error.message}`) } } catch (err) { console.error('Network error:', err) }
Last updated on