Create a ParseEpisodeError and replace bail! invocations.
This commit is contained in:
parent
d0ae5a4198
commit
008f57bec4
@ -44,6 +44,8 @@ pub enum DataError {
|
||||
status_code: hyper::StatusCode,
|
||||
context: String,
|
||||
},
|
||||
#[fail(display = "Error occured while Parsing an Episode. Reason: {}", reason)]
|
||||
ParseEpisodeError { reason: String, parent_id: i32 },
|
||||
}
|
||||
|
||||
impl From<RunMigrationsError> for DataError {
|
||||
|
||||
@ -52,11 +52,11 @@ impl Feed {
|
||||
info!("Indexing {} episodes.", insert.len());
|
||||
if let Err(err) = dbqueries::index_new_episodes(insert.as_slice()) {
|
||||
error!("Failed batch indexng, Fallign back to individual indexing.");
|
||||
error!("Error: {}", err);
|
||||
error!("{}", err);
|
||||
insert.iter().for_each(|ep| {
|
||||
if let Err(err) = ep.index() {
|
||||
error!("Failed to index episode: {:?}.", ep.title());
|
||||
error!("Error msg: {}", err);
|
||||
error!("{}", err);
|
||||
};
|
||||
})
|
||||
}
|
||||
@ -73,7 +73,7 @@ impl Feed {
|
||||
.for_each(|(ref ep, rowid)| {
|
||||
if let Err(err) = ep.update(rowid) {
|
||||
error!("Failed to index episode: {:?}.", ep.title());
|
||||
error!("Error msg: {}", err);
|
||||
error!("{}", err);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
@ -184,9 +184,12 @@ impl PartialEq<EpisodeMinimal> for NewEpisodeMinimal {
|
||||
impl NewEpisodeMinimal {
|
||||
pub(crate) fn new(item: &rss::Item, parent_id: i32) -> Result<Self, DataError> {
|
||||
if item.title().is_none() {
|
||||
return Err(DataError::DiscountBail(format!(
|
||||
"No title specified for the item."
|
||||
)));
|
||||
let err = DataError::ParseEpisodeError {
|
||||
reason: format!("No title specified for this Episode."),
|
||||
parent_id,
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
}
|
||||
|
||||
let title = item.title().unwrap().trim().to_owned();
|
||||
@ -197,9 +200,12 @@ impl NewEpisodeMinimal {
|
||||
} else if item.link().is_some() {
|
||||
item.link().map(|s| url_cleaner(s))
|
||||
} else {
|
||||
return Err(DataError::DiscountBail(format!(
|
||||
"No url specified for the item."
|
||||
)));
|
||||
let err = DataError::ParseEpisodeError {
|
||||
reason: format!("No url specified for the item."),
|
||||
parent_id,
|
||||
};
|
||||
|
||||
return Err(err);
|
||||
};
|
||||
|
||||
// Default to rfc2822 represantation of epoch 0.
|
||||
|
||||
@ -25,7 +25,7 @@ fn download_checker() -> Result<(), DataError> {
|
||||
ep.set_local_uri(None);
|
||||
if let Err(err) = ep.save() {
|
||||
error!("Error while trying to update episode: {:#?}", ep);
|
||||
error!("Error: {}", err);
|
||||
error!("{}", err);
|
||||
};
|
||||
});
|
||||
|
||||
@ -47,7 +47,7 @@ fn played_cleaner() -> Result<(), DataError> {
|
||||
if now_utc > limit {
|
||||
if let Err(err) = delete_local_content(ep) {
|
||||
error!("Error while trying to delete file: {:?}", ep.local_uri());
|
||||
error!("Error: {}", err);
|
||||
error!("{}", err);
|
||||
} else {
|
||||
info!("Episode {:?} was deleted succesfully.", ep.local_uri());
|
||||
};
|
||||
@ -67,7 +67,7 @@ fn delete_local_content(ep: &mut EpisodeCleanerQuery) -> Result<(), DataError> {
|
||||
ep.save()?;
|
||||
} else {
|
||||
error!("Error while trying to delete file: {}", uri);
|
||||
error!("Error: {}", res.unwrap_err());
|
||||
error!("{}", res.unwrap_err());
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user