refactor!: refactored response models

doc: documented all public methods
This commit is contained in:
ThetaDev 2022-12-09 01:01:25 +01:00
parent 4c1876cb55
commit f526ab38eb
37 changed files with 600 additions and 255 deletions

View file

@ -1,3 +1,5 @@
//! RustyPipe error types
use std::borrow::Cow;
/// Custom error type for the RustyPipe library
@ -16,8 +18,10 @@ pub enum Error {
/// Error from the HTTP client
#[error("http error: {0}")]
Http(#[from] reqwest::Error),
/// Erroneous HTTP status code received
#[error("http status code: {0}")]
HttpStatus(u16),
/// Unspecified error
#[error("error: {0}")]
Other(Cow<'static, str>),
}
@ -33,11 +37,13 @@ pub enum DeobfError {
/// Error during JavaScript execution
#[error("js execution error: {0}")]
JavaScript(#[from] quick_js::ExecutionError),
/// Error during JavaScript parsing
#[error("js parsing: {0}")]
JsParser(#[from] ress::error::Error),
/// Could not extract certain data
#[error("could not extract {0}")]
Extraction(&'static str),
/// Unspecified error
#[error("error: {0}")]
Other(&'static str),
}
@ -46,22 +52,44 @@ pub enum DeobfError {
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum ExtractionError {
/// Video cannot be extracted with RustyPipe
///
/// Reasons include:
/// - Deletion/Censorship
/// - Private video that requires a Google account
/// - DRM (Movies and TV shows)
#[error("Video cant be played because of {0}. Reason (from YT): {1}")]
VideoUnavailable(&'static str, String),
/// Video cannot be extracted because it is age restricted.
///
/// Age restriction may be circumvented with the [`crate::client::ClientType::TvHtml5Embed`] client.
#[error("Video is age restricted")]
VideoAgeRestricted,
/// Video cannot be extracted because it is not available in your country
#[error("Video is not available in your country")]
VideoGeoblocked,
/// Video cannot be extracted with the specified client
#[error("Video cant be played with this client. Reason (from YT): {0}")]
VideoClientUnsupported(String),
/// Content is not available / does not exist
#[error("Content is not available. Reason: {0}")]
ContentUnavailable(Cow<'static, str>),
/// Error deserializing YouTube's response JSON
#[error("deserialization error: {0}")]
Deserialization(#[from] serde_json::Error),
/// YouTube returned invalid data
#[error("got invalid data from YT: {0}")]
InvalidData(Cow<'static, str>),
/// YouTube returned data that does not match the queried ID
///
/// Specifically YouTube may return this video <https://www.youtube.com/watch?v=aQvGIIdgFDM>,
/// which is a 5 minute error message, instead of the requested video when using an outdated
/// Android client.
#[error("got wrong result from YT: {0}")]
WrongResult(String),
/// Warnings occurred during deserialization/mapping
///
/// This error is only returned in strict mode.
#[error("Warnings during deserialization/mapping")]
DeserializationWarnings,
}