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

Function convert_remote_error

atomic-cli/tests/fixtures/helpers_c5.rs:433–480  ·  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.

(err: RemoteError, url: &str)

Source from the content-addressed store, hash-verified

431///
432/// A `CliError` that can be displayed to the user.
433pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
434 match err {
435 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
436 message: format!("Failed to connect: {}", err),
437 url: Some(url.to_string()),
438 },
439 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
440 remote: url.to_string(),
441 },
442 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
443 message: "Repository not found on remote".to_string(),
444 url: Some(url.to_string()),
445 },
446 RemoteError::StackNotFound { stack } => CliError::RemoteError {
447 message: format!("Stack '{}' not found on remote", stack),
448 url: Some(url.to_string()),
449 },
450 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
451 RemoteError::MissingDependencies {
452 count,
453 missing_hashes,
454 } => CliError::MissingDependency {
455 change: "uploaded change".to_string(),
456 dependency: if missing_hashes.is_empty() {
457 format!("{} dependencies", count)
458 } else {
459 missing_hashes.join(", ")
460 },
461 },
462 RemoteError::StateMismatch {
463 remote_state,
464 requested_state,
465 } => CliError::Conflict {
466 description: format!(
467 "State mismatch: remote is at {}, requested {}",
468 remote_state, requested_state
469 ),
470 },
471 RemoteError::Timeout { seconds } => CliError::RemoteError {
472 message: format!("Request timed out after {} seconds", seconds),
473 url: Some(url.to_string()),
474 },
475 _ => CliError::RemoteError {
476 message: err.to_string(),
477 url: Some(url.to_string()),
478 },
479 }
480}
481
482// =============================================================================
483// Display Helpers

Callers 7

upload_change_smartFunction · 0.70
test_convert_auth_failedFunction · 0.70
test_convert_timeoutFunction · 0.70

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected