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
| Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource doesn’t exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Error Codes
Authentication Errors
INVALID_API_KEY- The API key is invalidEXPIRED_API_KEY- The API key has expiredINSUFFICIENT_PERMISSIONS- The API key lacks required permissions
Validation Errors
INVALID_REQUEST- The request format is invalidMISSING_FIELD- A required field is missingINVALID_FIELD- A field value is invalid
Resource Errors
NOT_FOUND- The requested resource was not foundALREADY_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