1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("TAP Node error: {0}")]
8 TapNode(#[from] tap_node::error::Error),
9
10 #[error("TAP Storage error: {0}")]
11 TapStorage(#[from] tap_node::storage::error::StorageError),
12
13 #[error("TAP Agent error: {0}")]
14 TapAgent(#[from] tap_agent::error::Error),
15
16 #[error("TAP Message error: {0}")]
17 TapMessage(#[from] tap_msg::error::Error),
18
19 #[error("IO error: {0}")]
20 Io(#[from] std::io::Error),
21
22 #[error("JSON error: {0}")]
23 Json(#[from] serde_json::Error),
24
25 #[error("Invalid parameter: {0}")]
26 InvalidParameter(String),
27
28 #[error("Command failed: {0}")]
29 CommandFailed(String),
30
31 #[error("Configuration error: {0}")]
32 Configuration(String),
33}
34
35impl Error {
36 pub fn invalid_parameter(msg: impl Into<String>) -> Self {
37 Self::InvalidParameter(msg.into())
38 }
39
40 pub fn command_failed(msg: impl Into<String>) -> Self {
41 Self::CommandFailed(msg.into())
42 }
43
44 pub fn configuration(msg: impl Into<String>) -> Self {
45 Self::Configuration(msg.into())
46 }
47}