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

Function convert_remote_error

atomic-cli/tests/fixtures/helpers_c1.rs:194–241  ·  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

192///
193/// A `CliError` that can be displayed to the user.
194pub fn convert_remote_error(err: RemoteError, url: &str) -> CliError {
195 match err {
196 RemoteError::ConnectionFailed { .. } => CliError::RemoteError {
197 message: format!("Failed to connect: {}", err),
198 url: Some(url.to_string()),
199 },
200 RemoteError::AuthenticationFailed { .. } => CliError::AuthenticationFailed {
201 remote: url.to_string(),
202 },
203 RemoteError::RepositoryNotFound { .. } => CliError::RemoteError {
204 message: "Repository not found on remote".to_string(),
205 url: Some(url.to_string()),
206 },
207 RemoteError::StackNotFound { stack } => CliError::RemoteError {
208 message: format!("Stack '{}' not found on remote", stack),
209 url: Some(url.to_string()),
210 },
211 RemoteError::ChangeNotFound { hash } => CliError::ChangeNotFound { hash },
212 RemoteError::MissingDependencies {
213 count,
214 missing_hashes,
215 } => CliError::MissingDependency {
216 change: "uploaded change".to_string(),
217 dependency: if missing_hashes.is_empty() {
218 format!("{} dependencies", count)
219 } else {
220 missing_hashes.join(", ")
221 },
222 },
223 RemoteError::StateMismatch {
224 remote_state,
225 requested_state,
226 } => CliError::Conflict {
227 description: format!(
228 "State mismatch: remote is at {}, requested {}",
229 remote_state, requested_state
230 ),
231 },
232 RemoteError::Timeout { seconds } => CliError::RemoteError {
233 message: format!("Request timed out after {} seconds", seconds),
234 url: Some(url.to_string()),
235 },
236 _ => CliError::RemoteError {
237 message: err.to_string(),
238 url: Some(url.to_string()),
239 },
240 }
241}
242
243// =============================================================================
244// Display Helpers

Callers 6

test_convert_auth_failedFunction · 0.70
test_convert_timeoutFunction · 0.70

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected