1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use alloc::borrow::Cow;

/// Errors that can occur during the id extraction or the video download process.   
#[derive(thiserror::Error, Debug)]
pub enum Error {
    #[error("the provided raw Id does not match any known Id-pattern")]
    BadIdFormat,
    #[cfg(any(feature = "fetch", doc))]
    #[doc(cfg(feature = "fetch"))]
    #[error("the video you requested is unavailable:\n{0:#?}")]
    VideoUnavailable(Box<crate::video_info::player_response::playability_status::PlayabilityStatus>),
    #[cfg(any(feature = "download", doc))]
    #[doc(cfg(feature = "download"))]
    #[error("the video contains no streams")]
    NoStreams,

    #[error(transparent)]
    #[cfg(any(feature = "fetch", doc))]
    #[doc(cfg(feature = "fetch"))]
    IO(#[from] std::io::Error),
    #[error(transparent)]
    #[cfg(any(feature = "fetch", doc))]
    #[doc(cfg(feature = "fetch"))]
    Request(#[from] reqwest::Error),
    #[error("YouTube returned an unexpected response: `{0}`")]
    UnexpectedResponse(Cow<'static, str>),
    #[error(transparent)]
    #[cfg(any(feature = "fetch", doc))]
    #[doc(cfg(feature = "fetch"))]
    QueryDeserialization(#[from] serde_qs::Error),
    #[error(transparent)]
    #[cfg(any(feature = "fetch", doc))]
    #[doc(cfg(feature = "fetch"))]
    JsonDeserialization(#[from] serde_json::Error),
    #[error(transparent)]
    UrlParseError(#[from] url::ParseError),

    #[error("{0}")]
    Custom(Cow<'static, str>),
    #[error("a potentially dangerous error occurred: {0}")]
    Fatal(String),
    #[error(
    "the error, which occurred is not meant an error, but is used for internal comunication.\
            This error should never be propagated to the public API."
    )]
    Internal(&'static str),
    #[error("The internal channel has been closed")]
    #[cfg(any(feature = "callback", doc))]
    #[doc(cfg(feature = "callback"))]
    ChannelClosed,
}