implement display for EcloadError
This commit is contained in:
parent
782fff9ac8
commit
eb7502f52e
4 changed files with 57 additions and 37 deletions
|
@ -1,3 +1,5 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Convert different errors into a common one.
|
||||
pub enum EcloadError {
|
||||
|
@ -8,6 +10,12 @@ pub enum EcloadError {
|
|||
ImageError(image::ImageError),
|
||||
}
|
||||
|
||||
impl fmt::Display for EcloadError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for EcloadError {
|
||||
fn from(e: std::io::Error) -> Self {
|
||||
EcloadError::StdError(e)
|
||||
|
|
|
@ -148,7 +148,7 @@ impl EcLoader {
|
|||
let image_bmp = match EcLoader::get_img_as_bmp(&entry.path()) {
|
||||
Ok(image_data) => image_data,
|
||||
Err(err) => {
|
||||
error!("could not decode {}: {:?}", entry.path().display(), err);
|
||||
error!("could not decode {}: {}", entry.path().display(), err);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
@ -179,7 +179,7 @@ impl EcLoader {
|
|||
}
|
||||
|
||||
let pdf_file_path = out_dir.join(format!("{}.pdf", title));
|
||||
info!("saved to {}", pdf_file_path.display());
|
||||
info!("saving to to {}...", pdf_file_path.display());
|
||||
let pdf_file = File::create(pdf_file_path)?;
|
||||
doc.save(&mut BufWriter::new(pdf_file))?;
|
||||
|
||||
|
@ -219,7 +219,7 @@ impl EcLoader {
|
|||
Ok(download_link) => download_link,
|
||||
Err(err) => {
|
||||
error!(
|
||||
"could not find download link for {} with format {}: {:?}",
|
||||
"could not find download link for {} with format {}: {}",
|
||||
&page_link, format, err
|
||||
);
|
||||
continue;
|
||||
|
@ -235,7 +235,7 @@ impl EcLoader {
|
|||
let mut page_download = match reqwest::get(&download_link) {
|
||||
Ok(response) => response,
|
||||
Err(err) => {
|
||||
error!("could not download {}: {:?}", download_link, err);
|
||||
error!("could not download {}: {}", download_link, err);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -77,7 +77,7 @@ fn main() {
|
|||
|
||||
match run(&out_path, size, id, title) {
|
||||
Ok(_) => info!("finished!"),
|
||||
Err(e) => error!("something went wrong: {:?}", e),
|
||||
Err(e) => error!("something went wrong: {}", e),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue