ibdl_core/
error.rs

1use std::{io, num::TryFromIntError};
2
3use ibdl_common::post::error::PostError;
4use ibdl_extractors::error::ExtractorError;
5use thiserror::Error;
6
7#[allow(clippy::enum_variant_names)]
8#[derive(Error, Debug)]
9pub enum QueueError {
10    #[error("Failed to access file: {source}")]
11    IOError {
12        #[from]
13        source: io::Error,
14    },
15
16    #[error("Failed to create destination directory. error: {message}")]
17    DirCreationError { message: String },
18
19    #[error("Failed to serialize data into summary file: {error}")]
20    SummarySerializeFail { error: String },
21
22    #[error("Failed to deserialize summary file: {error}")]
23    SummaryDeserializeFail { error: String },
24
25    #[error("Error while adding file to cbz file: {source}")]
26    ZipIOError {
27        #[from]
28        source: zip::result::ZipError,
29    },
30
31    #[error("Summary file in {file} not found or corrupted")]
32    ZipSummaryReadError { file: String },
33
34    #[error("No posts to download!")]
35    NoPostsInQueue,
36
37    #[error("Failed to print line to Progress Bar: {message}")]
38    ProgressBarPrintFail { message: String },
39
40    #[error("Int conversion failed (maybe size is too large?)")]
41    IntConversion(#[from] TryFromIntError),
42
43    #[error("Failed to download Post")]
44    PostDownloadError(#[from] PostError),
45}
46
47#[allow(clippy::enum_variant_names)]
48#[derive(Error, Debug)]
49pub enum CliError {
50    #[error("Failed to authenticate to imageboard: {source}")]
51    CoreAuthFail {
52        #[from]
53        source: ibdl_extractors::auth::Error,
54    },
55
56    #[error("Failed to authenticate to imageboard: {source}")]
57    InternalExtractorAuthFail {
58        #[from]
59        source: ExtractorError,
60    },
61
62    #[error("Failed to write input to console: {source}")]
63    DialoguerIOFail {
64        #[from]
65        source: dialoguer::Error,
66    },
67
68    #[error("Failed to access file: {source}")]
69    IOError {
70        #[from]
71        source: io::Error,
72    },
73
74    #[error("Whatever you did, it definetly shouldn't happen...")]
75    ImpossibleExecutionPath,
76
77    #[error("This operation is currently unsupported for this imageboard")]
78    ExtractorUnsupportedMode,
79
80    #[error("Failed to read server config")]
81    ServerConfigSerializeFail,
82
83    #[error("Selected server does not exist.")]
84    ServerNotExists,
85
86    #[error("No posts given")]
87    NoPostsInInput,
88}