caretta-sync/core/src/error.rs

46 lines
1.6 KiB
Rust
Raw Normal View History

2025-08-20 06:50:35 +09:00
use std::ffi::OsString;
2025-05-24 09:17:45 +09:00
#[derive(thiserror::Error, Debug)]
pub enum Error {
2025-06-01 15:18:17 +09:00
#[error("Base64 decode error: {0}")]
Base64Decode(#[from] base64::DecodeError),
2025-06-18 08:36:01 +09:00
#[error(transparent)]
CiborDeserialize(#[from] ciborium::de::Error<std::io::Error>),
#[error(transparent)]
CiborSerialize(#[from] ciborium::ser::Error<std::io::Error>),
2025-08-21 07:40:33 +09:00
#[error("Config error: {0}")]
Config(#[from] crate::config::error::ConfigError),
2025-05-25 17:19:37 +09:00
#[error("DB Error: {0}")]
Db(#[from]sea_orm::DbErr),
2025-06-01 15:18:17 +09:00
#[error("Dial Error: {0}")]
Dial(#[from] libp2p::swarm::DialError),
#[error("Decoding identity error: {0}")]
IdentityDecoding(#[from] libp2p::identity::DecodingError),
#[error("Infallible: {0}")]
Infallible(#[from] std::convert::Infallible),
2025-05-30 09:26:47 +09:00
#[error("IO Error: {0}")]
Io(#[from]std::io::Error),
2025-05-24 09:17:45 +09:00
#[error("mandatory config `{0}` is missing")]
2025-06-01 15:18:17 +09:00
MissingConfig(&'static str),
#[error("Multiaddr error: {0}")]
Multiaddr(#[from] libp2p::multiaddr::Error),
#[error("Noise error: {0}")]
Noise(#[from] libp2p::noise::Error),
2025-08-20 06:50:35 +09:00
#[error("Parse OsString error: {0:?}")]
OsStringConvert(std::ffi::OsString),
2025-06-18 08:36:01 +09:00
#[cfg(feature="desktop")]
#[error("Parse args error: {0}")]
ParseCommand(#[from] clap::Error),
2025-05-30 09:26:47 +09:00
#[error("toml deserialization error: {0}")]
TomlDe(#[from] toml::de::Error),
#[error("toml serialization error: {0}")]
2025-06-18 08:36:01 +09:00
TomlSer(#[from] toml::ser::Error),
2025-06-01 15:18:17 +09:00
#[error("Transport error: {0}")]
Transport(#[from]libp2p::TransportError<std::io::Error>)
2025-08-20 06:50:35 +09:00
}
impl From<std::ffi::OsString> for Error {
fn from(s: OsString) -> Error {
Self::OsStringConvert(s)
}
2025-05-24 09:17:45 +09:00
}