syncthing_rs/
error.rs

1//! syncthing-rs specific Error and Result
2
3/// Main library error type
4#[derive(thiserror::Error, Debug)]
5pub enum Error {
6    #[error(transparent)]
7    InvalidHeaderError(#[from] reqwest::header::InvalidHeaderValue),
8
9    #[error(transparent)]
10    NetworkError(#[from] reqwest::Error),
11
12    #[error("failed to send event (no receivers)")]
13    SendEventError,
14
15    #[error("device ID was not set in response header")]
16    HeaderDeviceIDError,
17
18    #[error("could not convert header to string")]
19    HeaderParseError,
20
21    #[error("folder already in the configuration")]
22    DuplicateFolderError,
23
24    #[error("device already in the configuration")]
25    DuplicateDeviceError,
26
27    #[error("folder does not exist")]
28    UnknownFolderError,
29
30    #[error("device does not exist")]
31    UnknownDeviceError,
32}
33
34impl From<tokio::sync::broadcast::error::SendError<crate::types::events::Event>> for Error {
35    fn from(_: tokio::sync::broadcast::error::SendError<crate::types::events::Event>) -> Self {
36        Self::SendEventError
37    }
38}
39
40pub type Result<T> = std::result::Result<T, Error>;