ffdl/src/errors.rs
Daniel M 39af87fcb4 Reduce the number of HTTP HEAD requests
- Removed redundant http head requests that were used to query
  filesizes, even after the filesize was known already.
2021-04-01 22:05:50 +02:00

27 lines
683 B
Rust

use std::error::Error;
use std::fmt::{ self, Display, Formatter };
/// Result Boxed Error
pub type ResBE<T> = Result<T, Box<dyn Error>>;
#[allow(unused)]
#[derive(Clone, Debug)]
pub enum DlError {
BadHttpStatus,
ContentLengthUnknown,
Other(String)
}
impl Error for DlError {}
impl Display for DlError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
DlError::BadHttpStatus => write!(f, "Bad http response status"),
DlError::ContentLengthUnknown => write!(f, "Content-Length is unknown"),
DlError::Other(s) => write!(f, "Unknown download error: '{}'", s)
}
}
}