scl_lib/controller_utils/
error.rs1use crate::client;
3
4#[derive(Debug)]
7pub enum ControllerBasicError {
8 SclClient(client::Error),
10
11 System(String),
14
15 Application,
17
18 Configuration(String),
22}
23
24impl From<client::Error> for ControllerBasicError {
25 fn from(e: client::Error) -> Self {
26 Self::SclClient(e)
27 }
28}
29
30impl std::fmt::Display for ControllerBasicError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 ControllerBasicError::SclClient(e) => write!(f, "API error: {}", e),
34 ControllerBasicError::Application => write!(f, "Application error"),
35 ControllerBasicError::System(s) => write!(f, "System error: {}", s),
36 ControllerBasicError::Configuration(s) => write!(f, "Configuration error: {}", s),
37 }
38 }
39}
40
41impl std::error::Error for ControllerBasicError {
42 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
43 match self {
44 ControllerBasicError::SclClient(e) => Some(e),
45 _ => None,
46 }
47 }
48}