pass_it_on/
error.rs

1use thiserror::Error;
2
3/// Errors returned by pass-it-on library.
4#[derive(Error, Debug)]
5pub enum Error {
6    /// At least one [`Endpoint`][`crate::endpoints::Endpoint`] needs to be defined for a server.
7    #[error("At least one endpoint must be defined")]
8    MissingEndpoint,
9
10    /// At least one [`Interface`][`crate::interfaces::Interface`] needs to be defined for a server or client.
11    #[error("At least one interface must be defined")]
12    MissingInterface,
13
14    /// Validation failed for an [`InterfaceConfig`][`crate::interfaces::InterfaceConfig`].
15    #[error("Invalid Interface Configuration: {0}")]
16    InvalidInterfaceConfiguration(String),
17
18    /// Validation failed for an [`EndpointConfig`][`crate::endpoints::EndpointConfig`].
19    #[error("Invalid Endpoint Configuration: {0}")]
20    InvalidEndpointConfiguration(String),
21
22    /// matrix room name does not appear to be a room.
23    #[error("Room identifiers must start with # or !")]
24    InvalidMatrixRoomIdentifier,
25
26    /// Port needs to be in a valid u16 range.
27    #[error("Invalid port number, valid u16 value expected and got {0}")]
28    InvalidPortNumber(i64),
29
30    /// Call to an interface feature that is not enabled.
31    #[error("Interface feature {0} is not enabled")]
32    DisabledInterfaceFeature(String),
33
34    /// Return when an endpoint feature is called but not enabled
35    #[error("Endpoint feature {0} is not enabled")]
36    DisabledIEndpointFeature(String),
37
38    // ### Converting from other error types ###
39    /// Pass-thru [`std::io::Error`].
40    #[error("std::io Error: {0}")]
41    IOError(#[from] std::io::Error),
42
43    /// Pass-thru `serde_json::Error`.
44    #[error("Serde_json Error: {0}")]
45    SerdeJsonError(#[from] serde_json::Error),
46
47    #[cfg(feature = "parse-cfg")]
48    /// Pass-thru `toml::de::Error`.
49    #[error("Serde Toml Error: {0}")]
50    SerdeTomlError(#[from] toml::de::Error),
51
52    #[cfg(feature = "matrix")]
53    /// Pass-thru `matrix_sdk::Error`.
54    #[error("Matrix_SDK Error: {0}")]
55    MatrixSDKError(#[from] matrix_sdk::Error),
56
57    #[cfg(feature = "matrix")]
58    /// Pass-thru `matrix_sdk::ClientBuildError`.
59    #[error("Matrix ClientBuild Error: {0}")]
60    MatrixClientBuildError(#[from] matrix_sdk::ClientBuildError),
61
62    #[cfg(feature = "matrix")]
63    /// Pass-thru `matrix_sdk::encryption::secret_storage::SecretStorageError`.
64    #[error("Matrix SecretStorage Error: {0}")]
65    MatrixSecretStoreError(#[from] matrix_sdk::encryption::secret_storage::SecretStorageError),
66
67    #[cfg(feature = "matrix")]
68    /// Pass-thru `matrix_sdk::encryption::recovery::RecoveryError`.
69    #[error("Matrix RecoveryError Error: {0}")]
70    MatrixRecoveryError(#[from] matrix_sdk::encryption::recovery::RecoveryError),
71
72    #[cfg(all(unix, any(feature = "pipe-client", feature = "pipe-server", feature = "pipe")))]
73    /// Pass-thru `nix::errno::Errno`.
74    #[error("Nix ErrorNo Error: {0}")]
75    NixErrorNoError(#[from] nix::errno::Errno),
76
77    #[cfg(any(feature = "http-client", feature = "http-server"))]
78    /// Pass-thru `url::ParseError`.
79    #[error("Url Parse Error: {0}")]
80    UrlParseError(#[from] url::ParseError),
81
82    #[cfg(feature = "email")]
83    /// Pass-thru `mail_send::Error`.
84    #[error("Mail Send Error: {0}")]
85    MailSendError(#[from] mail_send::Error),
86}