Converts a tonic transport error into a ClientApiError This implementation handles different transport error scenarios: - Connection timeouts - Invalid URI/address formats - Unexpected connection loss # Parameters - `err`: The tonic transport error to convert # Returns A ClientApiError with appropriate error code and retry information
(err: tonic::transport::Error)
| 112 | /// # Returns |
| 113 | /// A ClientApiError with appropriate error code and retry information |
| 114 | fn from(err: tonic::transport::Error) -> Self { |
| 115 | // Determine the error details based on the underlying error |
| 116 | if let Some(io_err) = err.source().and_then(|e| e.downcast_ref::<std::io::Error>()) |
| 117 | && io_err.kind() == std::io::ErrorKind::TimedOut |
| 118 | { |
| 119 | return Self::Network { |
| 120 | code: ErrorCode::ConnectionTimeout, |
| 121 | message: format!("Connection timeout: {err}"), |
| 122 | retry_after_ms: Some(3000), // Retry after 3 seconds |
| 123 | leader_hint: None, |
| 124 | }; |
| 125 | } |
| 126 | |
| 127 | // Default case: unexpected transport failure |
| 128 | Self::Network { |
| 129 | code: ErrorCode::Uncategorized, |
| 130 | message: format!("Transport error: {err}"), |
| 131 | retry_after_ms: Some(5000), |
| 132 | leader_hint: None, |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | impl From<Status> for ClientApiError { |
nothing calls this directly
no test coverage detected