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

Function convert_remote_error

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

538/// }
539/// ```
540pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
541 match err {
542 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
543 message: format!("Failed to connect: {}", err),
544 url: Some(url.to_string()),
545 },
546 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
547 remote: url.to_string(),
548 },
549 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
550 message: "Repository not found on remote".to_string(),
551 url: Some(url.to_string()),
552 },
553 RemoteError::ViewNotFound { view } => CliError::RemoteError {
554 message: format!("View '{}' not found on remote", view),
555 url: Some(url.to_string()),
556 },
557 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
558 RemoteError::TagNotFound { state } => CliError::RemoteError {
559 message: format!("Tag not found for state: {}", state),
560 url: Some(url.to_string()),
561 },
562 RemoteError::MissingDependencies {
563 count,
564 missing_hashes,
565 } => CliError::MissingDependency {
566 change: "requested change".to_string(),
567 dependency: if missing_hashes.is_empty() {
568 format!("{} dependencies", count)
569 } else {
570 missing_hashes.join(", ")
571 },
572 },
573 RemoteError::StateMismatch {
574 remote_state,
575 requested_state,
576 } => CliError::Conflict {
577 description: format!(
578 "State mismatch: remote is at {}, requested {}",
579 remote_state, requested_state
580 ),
581 },
582 RemoteError::Timeout { seconds } => CliError::RemoteError {
583 message: format!("Request timed out after {} seconds", seconds),
584 url: Some(url.to_string()),
585 },
586 RemoteError::EmptyView { view } => CliError::RemoteError {
587 message: format!("View '{}' is empty", view),
588 url: Some(url.to_string()),
589 },
590 _ => CliError::RemoteError {
591 message: err.to_string(),
592 url: Some(url.to_string()),
593 },
594 }
595}
596
597// Formatting Utilities

Callers 12

manifest_fetch_errorMethod · 0.70
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