rustypaste_cli/
error.rs

1use thiserror::Error as ThisError;
2
3/// Custom error type.
4#[derive(Debug, ThisError)]
5pub enum Error {
6    /// Error that might occur while handling I/O operations.
7    #[error("IO error: `{0}`")]
8    IoError(#[from] std::io::Error),
9    /// Error that might occur while parsing the configuration file.
10    #[error("TOML parsing error: `{0}`")]
11    TomlError(#[from] toml::de::Error),
12    /// Error that might occur while processing/sending requests.
13    #[error("Request error: `{0}`")]
14    RequestError(#[from] Box<ureq::Error>),
15    /// Error that might occur while uploading files.
16    #[error("Upload error: `{0}`")]
17    UploadError(String),
18    /// Error that might occur while deleting files from server.
19    #[error("Delete error: `{0}`")]
20    DeleteError(String),
21    /// Error that might occur when no server address is provided.
22    #[error("No rustypaste server address is given.")]
23    NoServerAddressError,
24    /// Error that might occur during the preparation of the multipart data.
25    #[error("Multipart IO error: `{0}`")]
26    MultipartIOError(#[from] multipart::client::lazy::LazyError<'static, std::io::Error>),
27    /// Error that might occur during parsing URLs.
28    #[error("URL parsing error: `{0}`")]
29    UrlParseError(#[from] url::ParseError),
30    /// Error that might occur during parsing a progress bar template.
31    #[error("Template parsing error: `{0}`")]
32    TemplateParseError(#[from] indicatif::style::TemplateError),
33}
34
35/// Type alias for the Result type.
36pub type Result<T> = std::result::Result<T, Error>;