Skip to main content

ac_rustube/
error.rs

1use alloc::borrow::Cow;
2
3/// Errors that can occur during the id extraction or the video download process.   
4#[derive(thiserror::Error, Debug)]
5pub enum Error {
6    #[error("the provided raw Id does not match any known Id-pattern")]
7    BadIdFormat,
8    #[cfg(feature = "fetch")]
9    #[error("the video you requested is unavailable:\n{0:#?}")]
10    VideoUnavailable(Box<crate::video_info::player_response::playability_status::PlayabilityStatus>),
11    #[cfg(feature = "download")]
12    #[error("the video contains no streams")]
13    NoStreams,
14
15    #[error(transparent)]
16    #[cfg(feature = "fetch")]
17    IO(#[from] std::io::Error),
18    #[error(transparent)]
19    #[cfg(feature = "fetch")]
20    Request(#[from] reqwest::Error),
21    #[error("YouTube returned an unexpected response: `{0}`")]
22    UnexpectedResponse(Cow<'static, str>),
23    #[error(transparent)]
24    #[cfg(feature = "fetch")]
25    QueryDeserialization(#[from] serde_qs::Error),
26    #[error(transparent)]
27    #[cfg(feature = "fetch")]
28    JsonDeserialization(#[from] serde_json::Error),
29    #[error(transparent)]
30    UrlParseError(#[from] url::ParseError),
31
32    #[error("{0}")]
33    Custom(Cow<'static, str>),
34    #[error("a potentially dangerous error occurred: {0}")]
35    Fatal(String),
36    #[error(
37    "the error, which occurred is not meant an error, but is used for internal comunication.\
38            This error should never be propagated to the public API."
39    )]
40    Internal(&'static str),
41    #[error("The internal channel has been closed")]
42    #[cfg(feature = "callback")]
43    ChannelClosed,
44}