Error Handling
How to handle errors when integrating with the Distribution Hub XML API.
Error Types
DH returns errors at two levels:
1. HTTP Status Codes
Transport-level errors from the HTTP layer.
| Status Code | Meaning | Retry? | Action |
|---|---|---|---|
200 OK | Request accepted | N/A | Parse XML for business status |
400 Bad Request | Malformed XML | ❌ No | Fix request format |
401 Unauthorized | Invalid API key | ❌ No | Verify the AccessKey / SecretKey pair |
404 Not Found | Invalid endpoint | ❌ No | Check API URL |
429 Too Many Requests | Rate limit exceeded | ✅ Yes | Back off; prefer Retry-After if present |
500 Internal Server Error | Server error | ✅ Yes | Exponential backoff (stop after 3–4 attempts) |
502 Bad Gateway | Gateway error | ✅ Yes | Retry with backoff |
503 Service Unavailable | Temporarily unavailable | ✅ Yes | Retry with backoff |
504 Gateway Timeout | Request timeout | ✅ Yes | Retry with backoff; consider a longer timeout |
2. XML Business Logic Status
Even with HTTP 200, check the XML Status block. When Success is false, use ErrorCode and ErrorMessage to decide what to do:
<Pull_ListProp_RS>
<Status>
<Success>false</Success>
<ErrorCode>PropertyNotFound</ErrorCode>
<ErrorMessage>Property with ID 12345 not found</ErrorMessage>
</Status>
</Pull_ListProp_RS>
Common Business Logic Errors
| Error Code | Meaning | Retry? | Action |
|---|---|---|---|
PropertyNotFound | Property doesn't exist | ❌ No | Remove from local cache |
PropertyNotActive | Property not available | ❌ No | Mark as inactive |
InvalidDates | Date range invalid | ❌ No | Validate date logic |
NotAvailable | Property not available for dates | ❌ No | Show as unavailable |
MinStayNotMet | Stay too short | ❌ No | Enforce minimum stay |
PriceChanged | Price changed since quote | ❌ No | Get a fresh quote |
ReservationNotFound | Reservation doesn't exist | ❌ No | Check reservation ID |
InvalidOwnerID | Owner doesn't exist | ❌ No | Check owner ID |
AuthenticationFailed | API key invalid | ❌ No | Correct or rotate the API key |
Retry Strategy
Retry only transient failures: rate limits (429), server errors (500, 502, 503, 504), timeouts, and connection errors. Do not retry client errors such as 400, 401, 403, or 404 — fix the request instead.
Use exponential backoff: wait longer between each retry so you don’t hammer the API while it recovers. A simple schedule is:
- First attempt — immediate
- Second attempt — wait ~1 second
- Third attempt — wait ~2 seconds
- Fourth attempt — wait ~4 seconds
Then stop (typically after 3–4 attempts) and surface the error. Double the wait each time (1 → 2 → 4…). For 429 responses, prefer any Retry-After value the API returns over your own backoff interval.
Error Handling by Operation Type
Dictionary operations
Failures are rare and usually transient. Keep a local cache of dictionary data and fall back to it if a sync fails. Schedule a later retry (for example within the hour) rather than blocking other work.
Property operations
PropertyNotFound and PropertyNotActive are common. Treat them as definitive: deactivate or mark the listing inactive in your system and stop syncing it until it becomes available again. Do not keep retrying the same property indefinitely.
Availability and pricing operations
Validate date ranges before calling the API. On InvalidDates, fix the request and do not cache the failed result. On PropertyNotFound, deactivate locally as above. On transient HTTP failures, use the retry schedule.
Booking operations
Treat booking errors as critical. Always obtain a fresh price quote immediately before creating a reservation. If the property is unavailable, the price changed, or minimum stay is not met, show a clear message to the guest and let them adjust dates or accept the new price — do not silently retry create. On server errors during booking, alert your operations team and ask the guest to try again or contact support. Avoid blind retries of create calls, which can produce duplicate reservations.
Error Logging
Retain API request and response details for at least 30 days to support troubleshooting. For each failure, log enough context to reproduce the call:
- Timestamp and duration
- HTTP status and business
ErrorCode/ErrorMessage - Operation name
- Full request and response XML
- Property ID and reservation ID when present
- Retry attempt number
- A correlation ID so you can trace one guest or sync job across systems
Circuit Breaker
If the API is repeatedly failing, stop calling it for a short period so you don’t amplify the outage.
- Closed (normal) — calls go through. Count consecutive failures.
- Open — after a threshold (for example 5 failures), pause outbound calls for a cooldown (for example 60 seconds) and alert ops.
- Half-open — after the cooldown, allow a limited probe call. Success closes the breaker; failure opens it again.
Use this for sync and quote traffic. Be especially careful with booking flows: when the breaker is open, fail fast with a clear guest-facing message rather than queuing ambiguous creates.
Best Practices
Do
- Retry transient errors with exponential backoff and a hard attempt limit
- Prefer
Retry-Afteron 429 responses - Log full request/response context (30+ days)
- Use a circuit breaker for resilience
- Alert on booking failures and breaker trips
- Map business error codes to clear guest or operator actions
Don’t
- Retry 400, 401, or 404
- Retry forever without a stop condition
- Ignore XML
Success=falsewhen HTTP status is 200 - Expose raw API error text to guests
- Blindly retry reservation create (duplicate risk)
Next Steps
- Rate Limiting — understand and manage rate limits
- Complete Integration Guide — put the pieces together