DataError: Improve the FeedRedirect variant
This commit is contained in:
parent
1ca4cb40dd
commit
3c5ddad133
@ -63,8 +63,8 @@ pub enum DataError {
|
|||||||
Bail(String),
|
Bail(String),
|
||||||
#[fail(display = "{}", _0)]
|
#[fail(display = "{}", _0)]
|
||||||
HttpStatusGeneral(HttpStatusError),
|
HttpStatusGeneral(HttpStatusError),
|
||||||
#[fail(display = "FIXME: This should be better")]
|
#[fail(display = "Source redirects to a new url")]
|
||||||
F301(Source),
|
FeedRedirect(Source),
|
||||||
#[fail(
|
#[fail(
|
||||||
display = "Error occured while Parsing an Episode. Reason: {}",
|
display = "Error occured while Parsing an Episode. Reason: {}",
|
||||||
reason
|
reason
|
||||||
|
|||||||
@ -146,13 +146,14 @@ impl Source {
|
|||||||
match code {
|
match code {
|
||||||
StatusCode::NotModified => return Err(self.make_err("304: skipping..", code)),
|
StatusCode::NotModified => return Err(self.make_err("304: skipping..", code)),
|
||||||
StatusCode::MovedPermanently | StatusCode::Found | StatusCode::PermanentRedirect => {
|
StatusCode::MovedPermanently | StatusCode::Found | StatusCode::PermanentRedirect => {
|
||||||
error!("Feed was moved permanently.");
|
warn!("Feed was moved permanently.");
|
||||||
self = self.update_url(&res)?;
|
self = self.update_url(&res)?;
|
||||||
return Err(DataError::F301(self));
|
return Err(DataError::FeedRedirect(self));
|
||||||
}
|
}
|
||||||
StatusCode::TemporaryRedirect => {
|
StatusCode::TemporaryRedirect => {
|
||||||
debug!("307: Temporary Redirect.");
|
warn!("307: Temporary Redirect.");
|
||||||
return Err(DataError::F301(self));
|
// FIXME: How is it actually handling the redirect?
|
||||||
|
return Err(DataError::FeedRedirect(self));
|
||||||
}
|
}
|
||||||
StatusCode::Unauthorized => return Err(self.make_err("401: Unauthorized.", code)),
|
StatusCode::Unauthorized => return Err(self.make_err("401: Unauthorized.", code)),
|
||||||
StatusCode::Forbidden => return Err(self.make_err("403: Forbidden.", code)),
|
StatusCode::Forbidden => return Err(self.make_err("403: Forbidden.", code)),
|
||||||
@ -212,7 +213,7 @@ impl Source {
|
|||||||
.then(|res| match res {
|
.then(|res| match res {
|
||||||
Ok(response) => Ok(Loop::Break(response)),
|
Ok(response) => Ok(Loop::Break(response)),
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
DataError::F301(s) => {
|
DataError::FeedRedirect(s) => {
|
||||||
info!("Following redirect...");
|
info!("Following redirect...");
|
||||||
Ok(Loop::Continue(s))
|
Ok(Loop::Continue(s))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user