1use std::{io, path::PathBuf};
2
3use tonic::{transport::Error as TransportError, Status};
4
5#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error("IO error: {0}")]
12 Io(#[from] io::Error),
13 #[error("Tonic transport error: {0}")]
15 Transport(#[from] TransportError),
16 #[error("Tonic error: {0}")]
18 Status(#[from] Status),
19 #[cfg(feature = "json")]
21 #[error("JSON (de-)serialization error: {0}")]
22 Json(#[from] serde_json::Error),
23 #[cfg(feature = "cbor")]
25 #[error("CBOR (de-)serialization error: {0}")]
26 Cbor(#[from] serde_cbor::Error),
27 #[error("PeerId parsing error: {0}")]
29 PeerId(#[from] libp2p_identity::ParseError),
30 #[error(transparent)]
32 Core(#[from] hyveos_core::Error),
33 #[error("Could not get {0}: {1}")]
35 EnvVarMissing(&'static str, #[source] std::env::VarError),
36 #[error("Path has no file name: {}", .0.display())]
38 NoFileName(PathBuf),
39 #[cfg(feature = "network")]
41 #[error("Invalid URI: {0}")]
42 InvalidUri(#[from] http::uri::InvalidUri),
43 #[cfg(feature = "network")]
45 #[error("Invalid URI: {0}")]
46 InvalidUriParts(#[from] http::uri::InvalidUriParts),
47 #[cfg(feature = "network")]
49 #[error("Invalid URL: {0}")]
50 InvalidUrl(#[from] url::ParseError),
51 #[cfg(feature = "network")]
52 #[error("Request error: {0}")]
54 Reqwest(#[from] reqwest::Error),
55 #[cfg(feature = "network")]
56 #[error("Got an error response: {0}")]
58 Response(String),
59}
60
61pub type Result<T, E = Error> = std::result::Result<T, E>;