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

Function convert_remote_error

atomic-cli/src/commands/pull/helpers.rs:243–298  ·  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

241/// }
242/// ```
243pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
244 match err {
245 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
246 message: format!("Failed to connect: {}", err),
247 url: Some(url.to_string()),
248 },
249 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
250 remote: url.to_string(),
251 },
252 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
253 message: "Repository not found on remote".to_string(),
254 url: Some(url.to_string()),
255 },
256 RemoteError::ViewNotFound { view } => CliError::RemoteError {
257 message: format!("View '{}' not found on remote", view),
258 url: Some(url.to_string()),
259 },
260 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
261 RemoteError::TagNotFound { state } => CliError::RemoteError {
262 message: format!("Tag not found for state: {}", state),
263 url: Some(url.to_string()),
264 },
265 RemoteError::MissingDependencies {
266 count,
267 missing_hashes,
268 } => CliError::MissingDependency {
269 change: "requested change".to_string(),
270 dependency: if missing_hashes.is_empty() {
271 format!("{} dependencies", count)
272 } else {
273 missing_hashes.join(", ")
274 },
275 },
276 RemoteError::StateMismatch {
277 remote_state,
278 requested_state,
279 } => CliError::Conflict {
280 description: format!(
281 "State mismatch: remote is at {}, requested {}",
282 remote_state, requested_state
283 ),
284 },
285 RemoteError::Timeout { seconds } => CliError::RemoteError {
286 message: format!("Request timed out after {} seconds", seconds),
287 url: Some(url.to_string()),
288 },
289 RemoteError::EmptyView { view } => CliError::RemoteError {
290 message: format!("View '{}' is empty", view),
291 url: Some(url.to_string()),
292 },
293 _ => CliError::RemoteError {
294 message: err.to_string(),
295 url: Some(url.to_string()),
296 },
297 }
298}
299
300// 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