use thiserror::Error;
use thiserror_ext::{Box, Construct};
#[derive(Error, Debug, Box, Construct)]
#[thiserror_ext(newtype(name = Error))]
pub enum ErrorKind {
#[error("At least one endpoint must be defined")]
MissingEndpoint,
#[error("At least one interface must be defined")]
MissingInterface,
#[error("Invalid Interface Configuration: {0}")]
InvalidInterfaceConfiguration(String),
#[error("Invalid Endpoint Configuration: {0}")]
InvalidEndpointConfiguration(String),
#[error("Room identifiers must start with # or !")]
InvalidMatrixRoomIdentifier,
#[error("Invalid port number, valid u16 value expected and got {0}")]
InvalidPortNumber(i64),
#[error("Interface feature {0} is not enabled")]
DisabledInterfaceFeature(String),
#[error("Endpoint feature {0} is not enabled")]
DisabledEndpointFeature(String),
#[error("std::io Error: {0}")]
IOError(#[from] std::io::Error),
#[error("Serde_json Error: {0}")]
SerdeJsonError(#[from] serde_json::Error),
#[cfg(feature = "parse-cfg")]
#[error("Serde Toml Error: {0}")]
SerdeTomlError(#[from] toml::de::Error),
#[cfg(feature = "matrix")]
#[error("Matrix_SDK Error: {0}")]
MatrixSDKError(#[from] matrix_sdk::Error),
#[cfg(feature = "matrix")]
#[error("Matrix ClientBuild Error: {0}")]
MatrixClientBuildError(#[from] matrix_sdk::ClientBuildError),
#[cfg(feature = "matrix")]
#[error("Matrix SecretStorage Error: {0}")]
MatrixSecretStoreError(#[from] matrix_sdk::encryption::secret_storage::SecretStorageError),
#[cfg(feature = "matrix")]
#[error("Matrix RecoveryError Error: {0}")]
MatrixRecoveryError(#[from] matrix_sdk::encryption::recovery::RecoveryError),
#[cfg(all(unix, any(feature = "pipe-client", feature = "pipe-server", feature = "pipe")))]
#[error("Nix ErrorNo Error: {0}")]
NixErrorNoError(#[from] nix::errno::Errno),
#[cfg(any(feature = "http-client", feature = "http-server"))]
#[error("Url Parse Error: {0}")]
UrlParseError(#[from] url::ParseError),
#[cfg(feature = "email")]
#[error("Mail Send Error: {0}")]
MailSendError(#[from] mail_send::Error),
}