exocore_transport/
error.rs1#[derive(Debug, thiserror::Error)]
3pub enum Error {
4 #[cfg(feature = "p2p-base")]
5 #[error("libp2p transport error: {0:?}")]
6 Libp2pTransport(#[source] std::sync::Arc<dyn std::error::Error + Send + Sync + 'static>),
7
8 #[error("Error in capnp serialization: {0}")]
9 Serialization(#[from] exocore_protos::capnp::Error),
10
11 #[error("Field is not in capnp schema: code={0}")]
12 SerializationNotInSchema(u16),
13
14 #[error("IO error: {0}")]
15 Io(#[from] std::io::Error),
16
17 #[error("Could not upgrade a weak reference")]
18 Upgrade,
19
20 #[error("Try to lock a mutex that was poisoned")]
21 Poisoned,
22
23 #[error("An error occurred: {0}")]
24 Other(String),
25}
26
27#[cfg(feature = "p2p-base")]
28impl<Terr> From<libp2p::core::transport::TransportError<Terr>> for Error
29where
30 Terr: std::error::Error + Send + Sync + 'static,
31{
32 fn from(err: libp2p::core::transport::TransportError<Terr>) -> Self {
33 Error::Libp2pTransport(std::sync::Arc::new(err))
34 }
35}
36
37impl From<exocore_protos::capnp::NotInSchema> for Error {
38 fn from(err: exocore_protos::capnp::NotInSchema) -> Self {
39 Error::SerializationNotInSchema(err.0)
40 }
41}
42
43impl<T> From<std::sync::PoisonError<T>> for Error {
44 fn from(_err: std::sync::PoisonError<T>) -> Self {
45 Error::Poisoned
46 }
47}