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

Function convert_remote_error

atomic-cli/src/commands/clone/helpers.rs:380–435  ·  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

378/// }
379/// ```
380pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
381 match err {
382 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
383 message: format!("Failed to connect: {}", err),
384 url: Some(url.to_string()),
385 },
386 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
387 remote: url.to_string(),
388 },
389 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
390 message: "Repository not found on remote".to_string(),
391 url: Some(url.to_string()),
392 },
393 RemoteError::ViewNotFound { view } => CliError::RemoteError {
394 message: format!("View '{}' not found on remote", view),
395 url: Some(url.to_string()),
396 },
397 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
398 RemoteError::TagNotFound { state } => CliError::RemoteError {
399 message: format!("Tag not found for state: {}", state),
400 url: Some(url.to_string()),
401 },
402 RemoteError::MissingDependencies {
403 count,
404 missing_hashes,
405 } => CliError::MissingDependency {
406 change: "requested change".to_string(),
407 dependency: if missing_hashes.is_empty() {
408 format!("{} dependencies", count)
409 } else {
410 missing_hashes.join(", ")
411 },
412 },
413 RemoteError::StateMismatch {
414 remote_state,
415 requested_state,
416 } => CliError::Conflict {
417 description: format!(
418 "State mismatch: remote is at {}, requested {}",
419 remote_state, requested_state
420 ),
421 },
422 RemoteError::Timeout { seconds } => CliError::RemoteError {
423 message: format!("Request timed out after {} seconds", seconds),
424 url: Some(url.to_string()),
425 },
426 RemoteError::EmptyView { view } => CliError::RemoteError {
427 message: format!("View '{}' is empty", view),
428 url: Some(url.to_string()),
429 },
430 _ => CliError::RemoteError {
431 message: err.to_string(),
432 url: Some(url.to_string()),
433 },
434 }
435}
436
437// Formatting Utilities

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