holodeck_simctl_core/
error.rs1use crate::models::{Simulator, SimulatorState};
2
3#[derive(Debug, thiserror::Error)]
4pub enum SimctlError {
5 #[error("Xcode not found")]
6 XcodeNotFound,
7
8 #[error("not found: {query}")]
9 SimulatorNotFound { query: String },
10
11 #[error("ambiguous: {query}")]
12 AmbiguousMatch { query: String, candidates: Vec<Simulator> },
13
14 #[error("already {}", state.raw_value())]
15 AlreadyInState { state: SimulatorState },
16
17 #[error("{}", command_failed_description(stderr))]
18 CommandFailed { command: String, exit_code: i32, stderr: String },
19
20 #[error("decode failed")]
21 DecodingFailed {
22 #[source]
23 underlying: Box<dyn std::error::Error + Send + Sync>,
24 },
25
26 #[error("{reason}")]
27 UnsupportedOperation { reason: String },
28
29 #[error(transparent)]
30 Io(#[from] std::io::Error),
31}
32
33fn command_failed_description(stderr: &str) -> String {
34 let trimmed = stderr.trim();
35 if trimmed.is_empty() { "command failed".to_string() } else { trimmed.to_string() }
36}