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

Function convert_remote_error

atomic-cli/tests/fixtures/helpers_c6.rs:377–424  ·  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

375///
376/// A `CliError` that can be displayed to the user.
377pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
378 match err {
379 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
380 message: format!("Failed to connect: {}", err),
381 url: Some(url.to_string()),
382 },
383 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
384 remote: url.to_string(),
385 },
386 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
387 message: "Repository not found on remote".to_string(),
388 url: Some(url.to_string()),
389 },
390 RemoteError::StackNotFound { stack } => CliError::RemoteError {
391 message: format!("Stack '{}' not found on remote", stack),
392 url: Some(url.to_string()),
393 },
394 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
395 RemoteError::MissingDependencies {
396 count,
397 missing_hashes,
398 } => CliError::MissingDependency {
399 change: "uploaded change".to_string(),
400 dependency: if missing_hashes.is_empty() {
401 format!("{} dependencies", count)
402 } else {
403 missing_hashes.join(", ")
404 },
405 },
406 RemoteError::StateMismatch {
407 remote_state,
408 requested_state,
409 } => CliError::Conflict {
410 description: format!(
411 "State mismatch: remote is at {}, requested {}",
412 remote_state, requested_state
413 ),
414 },
415 RemoteError::Timeout { seconds } => CliError::RemoteError {
416 message: format!("Request timed out after {} seconds", seconds),
417 url: Some(url.to_string()),
418 },
419 _ => CliError::RemoteError {
420 message: err.to_string(),
421 url: Some(url.to_string()),
422 },
423 }
424}
425
426// Display Helpers
427

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