1use std::{path::PathBuf, sync::Arc, time::Duration};
4
5use iroh::EndpointId;
6use moq_net::Path;
7use n0_error::{AnyError, stack_error};
8
9#[stack_error(derive, add_meta)]
14#[derive(Clone)]
15pub enum Error {
16 #[error("cannot claim {path} for its publisher")]
21 Claim {
22 path: Path,
23 #[error(source, std_err)]
24 source: Box<iroh_live_node::Error>,
25 },
26 #[error("failed to reach the publisher {}", peer.fmt_short())]
28 Connect {
29 peer: EndpointId,
30 #[error(source, std_err)]
31 source: Box<iroh_live_node::Error>,
32 },
33 #[error("failed to subscribe to {path}")]
35 Subscribe {
36 path: Path,
37 #[error(source, std_err)]
38 source: Box<iroh_live_node::Error>,
39 },
40 #[error("the publisher did not announce {path} within {timeout:?}")]
42 Timeout { path: Path, timeout: Duration },
43 #[error("pulling a ticket through this relay needs a token that grants reading {path}")]
47 PullDenied { path: Path },
48 #[error("the relay already holds its limit of {limit} pulls")]
50 PullLimit { limit: usize },
51 #[error("this client already holds its limit of {limit} pulls")]
53 ClientPullLimit { limit: usize },
54 #[error("this client started too many pulls recently, try again later")]
56 DialRateLimit,
57 #[error("the pull was dropped before it connected")]
59 Dropped,
60 #[error("no platform data directory, set IROH_LIVE_RELAY_DATA")]
62 NoDataDir,
63 #[error(
65 "cannot load the relay's identity. Deleting {} starts over, with a new \
66 endpoint id that invalidates every ticket naming the old one",
67 path.display()
68 )]
69 Identity {
70 path: PathBuf,
71 #[error(source, std_err)]
72 source: Arc<std::io::Error>,
73 },
74 #[error("the relay's iroh endpoint")]
76 Bind {
77 #[error(source, std_err)]
78 source: Arc<iroh_live_node::EndpointError>,
79 },
80 #[error("cannot read the JWT keys from {}", path.display())]
82 Keys {
83 path: PathBuf,
84 #[error(source, std_err)]
85 source: Arc<moq_auth::Error>,
86 },
87 #[error("the moq relay failed")]
89 Relay {
90 #[error(source, std_err)]
91 source: Arc<AnyError>,
92 },
93}