MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / convert_remote_error

Function convert_remote_error

atomic-cli/src/commands/pull/helpers.rs:225–280  ·  view source on GitHub ↗

Convert a remote error to a CLI error. Maps the various remote error types to appropriate CLI error types with user-friendly messages and suggestions. # Arguments `err` - The remote error to convert `url` - The remote URL (for context in error messages) # Returns A `CliError` that can be displayed to the user. # Example ```rust,ignore let result = remote.get_state("main").await; if let Err(

(err: RemoteError, url: &str)

Source from the content-addressed store, hash-verified

223/// }
224/// ```
225pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
226 match err {
227 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
228 message: format!("Failed to connect: {}", err),
229 url: Some(url.to_string()),
230 },
231 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
232 remote: url.to_string(),
233 },
234 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
235 message: "Repository not found on remote".to_string(),
236 url: Some(url.to_string()),
237 },
238 RemoteError::ViewNotFound { view } => CliError::RemoteError {
239 message: format!("View '{}' not found on remote", view),
240 url: Some(url.to_string()),
241 },
242 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
243 RemoteError::TagNotFound { state } => CliError::RemoteError {
244 message: format!("Tag not found for state: {}", state),
245 url: Some(url.to_string()),
246 },
247 RemoteError::MissingDependencies {
248 count,
249 missing_hashes,
250 } => CliError::MissingDependency {
251 change: "requested change".to_string(),
252 dependency: if missing_hashes.is_empty() {
253 format!("{} dependencies", count)
254 } else {
255 missing_hashes.join(", ")
256 },
257 },
258 RemoteError::StateMismatch {
259 remote_state,
260 requested_state,
261 } => CliError::Conflict {
262 description: format!(
263 "State mismatch: remote is at {}, requested {}",
264 remote_state, requested_state
265 ),
266 },
267 RemoteError::Timeout { seconds } => CliError::RemoteError {
268 message: format!("Request timed out after {} seconds", seconds),
269 url: Some(url.to_string()),
270 },
271 RemoteError::EmptyView { view } => CliError::RemoteError {
272 message: format!("View '{}' is empty", view),
273 url: Some(url.to_string()),
274 },
275 _ => CliError::RemoteError {
276 message: err.to_string(),
277 url: Some(url.to_string()),
278 },
279 }
280}
281
282// Display Helpers

Callers 11

run_asyncMethod · 0.70
test_convert_auth_failedFunction · 0.70
test_convert_timeoutFunction · 0.70
test_convert_empty_viewFunction · 0.70

Calls 1

is_emptyMethod · 0.45

Tested by 10

test_convert_auth_failedFunction · 0.56
test_convert_timeoutFunction · 0.56
test_convert_empty_viewFunction · 0.56