graph_error/
download.rs

1use crate::io_error::{AsyncIoError, ThreadedIoError};
2
3#[derive(Debug, thiserror::Error)]
4#[allow(clippy::large_enum_variant)]
5pub enum BlockingDownloadError {
6    #[error(transparent)]
7    Io(#[from] ThreadedIoError),
8
9    #[error("target directory does not exist {0}")]
10    TargetDoesNotExist(String),
11
12    #[error("request error: {0}")]
13    Request(#[from] reqwest::Error),
14
15    #[error("file name is too long (max 255 chars)")]
16    FileNameTooLong,
17
18    #[error("could not determine file name")]
19    NoFileName,
20
21    #[error(
22        "Download file already exists: {0}. \
23        If you want to over write this file then use overwrite_existing_file(true)"
24    )]
25    FileExists(String),
26
27    #[error("http::Error:\n{0:#?}")]
28    HttpError(#[from] http::Error),
29}
30
31impl From<std::io::Error> for BlockingDownloadError {
32    fn from(err: std::io::Error) -> Self {
33        Self::Io(ThreadedIoError::Std(err))
34    }
35}
36
37#[derive(Debug, thiserror::Error)]
38#[allow(clippy::large_enum_variant)]
39pub enum AsyncDownloadError {
40    #[error(transparent)]
41    Io(#[from] AsyncIoError),
42
43    #[error("target directory does not exist {0}")]
44    TargetDoesNotExist(String),
45
46    #[error("request error: {0}")]
47    Request(#[from] reqwest::Error),
48
49    #[error("file name is too long (max 255 chars)")]
50    FileNameTooLong,
51
52    #[error("could not determine file name")]
53    NoFileName,
54
55    #[error(
56        "Download file already exists: {0}. \
57        If you want to over write this file then use overwrite_existing_file(true)"
58    )]
59    FileExists(String),
60
61    #[error("http::Error:\n{0:#?}")]
62    HttpError(#[from] http::Error),
63}
64
65impl From<std::io::Error> for AsyncDownloadError {
66    fn from(err: std::io::Error) -> Self {
67        Self::Io(AsyncIoError::Std(err))
68    }
69}