1#[derive(Debug)]
6pub enum ShurikenError {
7 ServiceNotFound(String),
9 SpawnFailed(String, std::io::Error),
11 NoPid,
13 ConfigError(String),
15 ShurikensDirectoryNotFound,
17 InvalidServiceName,
19 ConfigParseError(String, toml::de::Error),
21 IoError(std::io::Error),
23}
24
25impl std::fmt::Display for ShurikenError {
26 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27 match self {
28 ShurikenError::ServiceNotFound(name) => write!(f, "Service '{}' not found", name),
29 ShurikenError::SpawnFailed(name, err) => {
30 write!(f, "Failed to spawn service '{}': {}", name, err)
31 }
32 ShurikenError::NoPid => write!(f, "Could not get process ID"),
33 ShurikenError::ConfigError(msg) => write!(f, "Configuration error: {}", msg),
34 ShurikenError::ShurikensDirectoryNotFound => write!(f, "Shurikens directory not found"),
35 ShurikenError::InvalidServiceName => write!(f, "Invalid service name"),
36 ShurikenError::ConfigParseError(name, err) => {
37 write!(f, "Failed to parse config for '{}': {}", name, err)
38 }
39 ShurikenError::IoError(err) => write!(f, "IO error: {}", err),
40 }
41 }
42}
43
44impl std::error::Error for ShurikenError {}
45
46impl From<std::io::Error> for ShurikenError {
48 fn from(err: std::io::Error) -> Self {
49 ShurikenError::IoError(err)
50 }
51}