pub fn map_http_error_to_reason(status_code: u16) -> (&'static str, String)Expand description
Map HTTP status code to condition reason and message.
This function converts HTTP status codes from Bindcar API responses into standardized Kubernetes condition reasons and human-readable messages.
§Arguments
status_code- HTTP status code (e.g., 400, 404, 500)
§Returns
A tuple of (reason, message):
reason- Constant fromstatus_reasonsmodulemessage- Human-readable explanation of the error
§HTTP Code Mapping
| HTTP Code | Reason | Meaning |
|---|---|---|
| 400 | BindcarBadRequest | Invalid request format |
| 401 | BindcarAuthFailed | Authentication required |
| 403 | BindcarAuthFailed | Insufficient permissions |
| 404 | ZoneNotFound | Resource not found |
| 500 | BindcarInternalError | Internal server error |
| 501 | BindcarNotImplemented | Feature not implemented |
| 502 | GatewayError | Bad gateway |
| 503 | GatewayError | Service unavailable |
| 504 | GatewayError | Gateway timeout |
| Other | BindcarUnreachable | Unexpected error |
§Example
use bindy::http_errors::map_http_error_to_reason;
let (reason, message) = map_http_error_to_reason(404);
assert_eq!(reason, "ZoneNotFound");
assert!(message.contains("404"));
let (reason, message) = map_http_error_to_reason(503);
assert_eq!(reason, "GatewayError");
assert!(message.contains("503"));