Error Handling
Error Handling
Understand error responses and implement robust error handling in your WMS integration.
Error Response Format
All API errors return a consistent JSON structure.
Error Response
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid SKU format",
"details": [
{
"field": "sku",
"message": "SKU must be alphanumeric"
}
],
"request_id": "req_abc123",
"documentation_url": "https://docs.synaptis.com/wms/errors#VALIDATION_ERROR"
}
}HTTP Status Codes
| Code | Name | Description | Retry |
|---|---|---|---|
| 400 | Bad Request | Invalid request parameters or malformed JSON | |
| 401 | Unauthorized | Missing or invalid API key | |
| 403 | Forbidden | Insufficient permissions for this operation | |
| 404 | Not Found | Resource does not exist | |
| 409 | Conflict | Resource conflict (e.g., duplicate SKU) | |
| 422 | Unprocessable | Validation error in request data | |
| 429 | Rate Limited | Too many requests | |
| 500 | Server Error | Internal server error | |
| 503 | Unavailable | Service temporarily unavailable |
Retry Strategy
Implement exponential backoff for retryable errors (429, 500, 503).
Exponential Backoff
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const response = await fetch(url, options);
if (response.ok) return response;
if (![429, 500, 503].includes(response.status)) {
throw new Error(`Non-retryable error: ${response.status}`);
}
const delay = Math.pow(2, attempt) * 1000;
await new Promise(r => setTimeout(r, delay));
} catch (error) {
if (attempt === maxRetries - 1) throw error;
}
}
}