1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::backtrace::Backtrace;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum DownloadError {
#[error("reqwest error->{source:?}")]
ReqwestError {
#[from]
source: reqwest::Error,
backtrace: Backtrace,
},
#[error("io error->{source:?}")]
IoError {
#[from]
source: std::io::Error,
backtrace: Backtrace,
},
#[error("not get file size ->{0:?}")]
NotGetFileSize(reqwest::Url),
#[error("save file is finish->{0:?}")]
SaveFileFinish(String),
#[error("not get file name ->{0:?}")]
NotFileName(reqwest::Url),
#[error("http error:{0}")]
HttpStatusError(String),
}
pub type Result<T> = std::result::Result<T, DownloadError>;