MCPcopy Create free account
hub / github.com/deventlab/d-engine / from

Method from

d-engine-core/src/client/client_api_error.rs:114–134  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
137impl From<Status> for ClientApiError {

Callers

nothing calls this directly

Calls 3

codeMethod · 0.80
messageMethod · 0.80

Tested by

no test coverage detected