fluence_app_service/
errors.rs1use marine_wasm_backend_traits::WasmBackendError;
18use marine::MarineError;
19
20use std::io::Error as IOError;
21use std::error::Error;
22use std::path::PathBuf;
23
24#[derive(Debug)]
25pub enum AppServiceError {
26 InvalidConfig(String),
28
29 IOError(IOError),
31
32 MarineError(MarineError),
34
35 WasmBackendError(WasmBackendError),
37
38 CreateDir {
40 err: IOError,
41 path: PathBuf,
42 },
43
44 ConfigParseError(String),
46}
47
48impl Error for AppServiceError {}
49
50impl std::fmt::Display for AppServiceError {
51 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
52 match self {
53 AppServiceError::InvalidConfig(err_msg) => write!(f, "{}", err_msg),
54 AppServiceError::IOError(err) => write!(f, "{}", err),
55 AppServiceError::MarineError(err) => write!(f, "{}", err),
56 AppServiceError::CreateDir { err, path } => {
57 write!(f, "Failed to create dir {:?}: {:?}", path, err)
58 }
59 AppServiceError::ConfigParseError(err_msg) => write!(f, "{}", err_msg),
60 AppServiceError::WasmBackendError(err) => {
61 write!(f, "{}", err)
62 }
63 }
64 }
65}
66
67impl From<MarineError> for AppServiceError {
68 fn from(err: MarineError) -> Self {
69 AppServiceError::MarineError(err)
70 }
71}
72
73impl From<IOError> for AppServiceError {
74 fn from(err: IOError) -> Self {
75 AppServiceError::IOError(err)
76 }
77}
78
79impl From<toml::de::Error> for AppServiceError {
80 fn from(err: toml::de::Error) -> Self {
81 AppServiceError::InvalidConfig(format!("{}", err))
82 }
83}
84
85impl From<std::convert::Infallible> for AppServiceError {
86 fn from(_: std::convert::Infallible) -> Self {
87 unreachable!()
88 }
89}