service_utils/error/
service_util_error.rs1use std::error::Error;
7use std::fmt;
8use std::fmt::Formatter;
9
10#[derive(Debug, Clone, Eq, PartialEq, Hash)]
11pub enum ServiceUtilError {
12 BinaryNotFound(String),
13 ServiceStartFailed(String),
14 ServiceAlreadyRunning(String),
15 ServiceHealthcheckFailed(String),
16 ServiceStopFailed(String),
17 ServiceNotSupported(String),
18 ServiceNotRunning(String),
19 UnsupportedWaitStrategy(String),
20 UnknownError(String),
21}
22
23impl Error for ServiceUtilError {}
24
25impl fmt::Display for ServiceUtilError {
26 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
27 match self {
28 Self::BinaryNotFound(e) => {
29 write!(f, "[ServiceUtilError]: Binary not found: {e}")
30 }
31 Self::ServiceStartFailed(e) => {
32 write!(f, "[ServiceUtilError]: Service start failed: {e}")
33 }
34 Self::ServiceAlreadyRunning(e) => {
35 write!(f, "[ServiceUtilError]: Service already running: {e}")
36 }
37 Self::ServiceHealthcheckFailed(e) => {
38 write!(f, "[ServiceUtilError]: Service healthcheck failed: {e}")
39 }
40 Self::ServiceStopFailed(e) => {
41 write!(f, "[ServiceUtilError]: Service stop failed: {e}")
42 }
43 Self::ServiceNotSupported(e) => {
44 write!(f, "[ServiceUtilError]: Service not supported: {e}")
45 }
46 Self::ServiceNotRunning(e) => {
47 write!(f, "[ServiceUtilError]: Service not running: {e}")
48 }
49 Self::UnsupportedWaitStrategy(e) => {
50 write!(f, "[ServiceUtilError]: Unsupported wait strategy: {e}")
51 }
52 Self::UnknownError(e) => {
53 write!(f, "[ServiceUtilError]: Unknown error: {e}")
54 }
55 }
56 }
57}