1#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum Error {
5 #[error("invalid SDP: {0}")]
7 InvalidSdp(String),
8
9 #[error("unsupported codec: {0}")]
11 UnsupportedCodec(String),
12
13 #[error("session not found")]
15 SessionNotFound,
16
17 #[error("session closed")]
19 SessionClosed,
20
21 #[error("ICE did not connect before the establishment deadline")]
23 IceTimeout,
24
25 #[error("catalog did not arrive before the negotiation deadline")]
27 CatalogTimeout,
28
29 #[error("catalog closed before its first snapshot")]
31 CatalogClosed,
32
33 #[error("catalog has no WebRTC-compatible renditions")]
35 NoRenditions,
36
37 #[error("no SDP changes to apply")]
39 NoSdpChanges,
40
41 #[error("io error: {0}")]
43 Io(#[from] std::io::Error),
44
45 #[error("moq error: {0}")]
47 Moq(#[from] moq_net::Error),
48
49 #[error("mux error: {0}")]
51 Mux(#[from] moq_mux::Error),
52
53 #[error("http error: {0}")]
55 Http(std::sync::Arc<reqwest::Error>),
56
57 #[error("HTTP endpoint returned status {0}")]
59 HttpStatus(u16),
60
61 #[error("rtc error: {0}")]
63 Rtc(String),
64
65 #[error("rtc input error: {0}")]
67 RtcInput(String),
68
69 #[error("video bridge initialization failed")]
71 BridgeFailed,
72}
73
74impl From<reqwest::Error> for Error {
75 fn from(err: reqwest::Error) -> Self {
76 Self::Http(std::sync::Arc::new(err))
77 }
78}
79
80impl Error {
81 pub(crate) fn rtc(err: impl std::fmt::Display) -> Self {
82 Self::Rtc(err.to_string())
83 }
84
85 pub(crate) fn rtc_input(err: impl std::fmt::Display) -> Self {
86 Self::RtcInput(err.to_string())
87 }
88}
89
90pub type Result<T> = std::result::Result<T, Error>;