feat: add more extraction errors
This commit is contained in:
parent
f748b98ccc
commit
68342cecab
4 changed files with 78 additions and 25 deletions
24
src/error.rs
24
src/error.rs
|
|
@ -73,6 +73,10 @@ pub enum ExtractionError {
|
|||
VideoUnavailable(&'static str, String),
|
||||
#[error("Video is age restricted")]
|
||||
VideoAgeRestricted,
|
||||
#[error("Video is not available in your country")]
|
||||
VideoGeoblock,
|
||||
#[error("Video cant be played with this client. Reason (from YT): {0}")]
|
||||
VideoClientUnsupported(String),
|
||||
#[error("Content is not available. Reason: {0}")]
|
||||
ContentUnavailable(Cow<'static, str>),
|
||||
#[error("deserialization error: {0}")]
|
||||
|
|
@ -84,3 +88,23 @@ pub enum ExtractionError {
|
|||
#[error("Warnings during deserialization/mapping")]
|
||||
DeserializationWarnings,
|
||||
}
|
||||
|
||||
impl ExtractionError {
|
||||
pub(crate) fn should_report(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ExtractionError::Deserialization(_)
|
||||
| ExtractionError::InvalidData(_)
|
||||
| ExtractionError::WrongResult(_)
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn switch_client(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
ExtractionError::VideoClientUnsupported(_)
|
||||
| ExtractionError::VideoAgeRestricted
|
||||
| ExtractionError::WrongResult(_)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue