diff options
Diffstat (limited to 'crates/core/tedge/src/system_services/error.rs')
-rw-r--r-- | crates/core/tedge/src/system_services/error.rs | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/crates/core/tedge/src/system_services/error.rs b/crates/core/tedge/src/system_services/error.rs new file mode 100644 index 00000000..1b2e8c1a --- /dev/null +++ b/crates/core/tedge/src/system_services/error.rs @@ -0,0 +1,63 @@ +#[derive(thiserror::Error, Debug)] +pub enum SystemServiceError { + #[error(transparent)] + IoError(#[from] std::io::Error), + + #[error(transparent)] + SystemdError(#[from] SystemdError), + + #[error(transparent)] + OpenRcServiceError(#[from] OpenRcServiceError), + + #[error(transparent)] + BsdServiceError(#[from] BsdServiceError), + + #[error("Unexpected value for exit status.")] + UnexpectedExitStatus, + + #[error("Unsupported operation.")] + UnsupportedOperation, + + #[error("Service Manager: '{0}' is not available on the system or elevated permissions have not been granted.")] + ServiceManagerUnavailable(String), +} + +/// The error type used by the `SystemdServiceManager` +#[derive(thiserror::Error, Debug)] +pub enum SystemdError { + #[error("Systemd returned unspecific error for service {service} while performing {cmd} it.\nHint: {hint}")] + UnspecificError { + service: &'static str, + cmd: &'static str, + hint: &'static str, + }, + + #[error("Service {service} not found. Install {service} to use this command.")] + ServiceNotFound { service: &'static str }, + + #[error("Service {service} not loaded.")] + ServiceNotLoaded { service: &'static str }, + + #[error("Returned exit code: '{code:?}' for: systemd' is unhandled.")] + UnhandledReturnCode { code: i32 }, +} + +/// The error type used by the `OpenRcServiceManager` +#[derive(thiserror::Error, Debug)] +pub enum OpenRcServiceError { + #[error("Service command <{service_command:?}> failed with code: {code:?}.")] + ServiceCommandFailed { + service_command: String, + code: Option<i32>, + }, +} + +/// The error type used by the `BsdServiceManager` +#[derive(thiserror::Error, Debug)] +pub enum BsdServiceError { + #[error("Service command <{service_command:?}> failed with code: {code:?}.")] + ServiceCommandFailed { + service_command: String, + code: Option<i32>, + }, +} |