Skip to main content

paperless_cli/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum AppError {
7    #[error("Paperless is not configured. Run `paperless login`.")]
8    ConfigMissing,
9    #[error("Config at {path} is malformed: {reason}")]
10    ConfigMalformed { path: PathBuf, reason: String },
11    #[error("Invalid Paperless URL: {0}")]
12    InvalidUrl(String),
13    #[error("Refusing insecure remote HTTP URL: {0}. Use HTTPS or a local loopback address.")]
14    InsecureRemoteUrl(String),
15    #[error("Provide either a token or both username and password.")]
16    MissingCredentials,
17    #[error("No fields supplied for update.")]
18    NoFieldsToUpdate,
19    #[error("File not found: {0}")]
20    FileMissing(PathBuf),
21    #[error("HTTP {status} from {url}: {message}")]
22    Http {
23        status: u16,
24        url: String,
25        message: String,
26    },
27    #[error("{0}")]
28    Message(String),
29    #[error(transparent)]
30    Io(#[from] std::io::Error),
31    #[error(transparent)]
32    Json(#[from] serde_json::Error),
33    #[error(transparent)]
34    TomlDeserialize(#[from] toml::de::Error),
35    #[error(transparent)]
36    TomlSerialize(#[from] toml::ser::Error),
37    #[error(transparent)]
38    Reqwest(#[from] reqwest::Error),
39}