Skip to main content

iroh_live/
error.rs

1//! The facade's error type.
2
3use n0_error::stack_error;
4
5/// An error from the node, the endpoint, rooms, calls, or the media.
6///
7/// Every variant carries the error's metadata after its source, so a match
8/// names it:
9///
10/// ```
11/// use iroh_live::{EndpointConfig, EndpointError, Error};
12///
13/// # async fn run() -> Result<(), Error> {
14/// let bound = EndpointConfig::from_env()?.bind().await;
15/// match bound.map_err(Error::from) {
16///     Ok(endpoint) => endpoint.close().await,
17///     Err(Error::Endpoint(EndpointError::Bind { .. }, _)) => eprintln!("cannot bind"),
18///     Err(other) => return Err(other),
19/// }
20/// # Ok(())
21/// # }
22/// ```
23#[stack_error(derive, add_meta, from_sources)]
24pub enum Error {
25    /// A peer was unreachable, or a path could not be resolved or published.
26    #[error(transparent)]
27    Node(iroh_live_node::Error),
28    /// `IROH_SECRET` held no secret key, or the endpoint could not be bound.
29    #[error(transparent)]
30    Endpoint(iroh_live_node::EndpointError),
31    /// A source, an encoder, a decoder or a recording failed.
32    #[cfg(any(feature = "player", feature = "publisher"))]
33    #[error(transparent)]
34    Media(moq_ext_sources::Error),
35    /// A room failed.
36    #[cfg(feature = "rooms")]
37    #[error(transparent)]
38    Rooms(iroh_live_rooms::Error),
39    /// A call could not be placed or answered.
40    #[error(transparent)]
41    Calls(crate::calls::Error),
42}