printnanny_settings/
error.rs1use std::path::PathBuf;
2use thiserror::Error;
3
4use printnanny_dbus::zbus;
5
6#[derive(Error, Debug)]
7pub enum PrintNannySettingsError {
8 #[error("PRINTNANNY_SETTINGS was set {path:?} but file was not found")]
9 ConfigFileNotFound { path: PathBuf },
10
11 #[error("Failed to unpack file {filename} from archive {archive:?}")]
12 ArchiveMissingFile { filename: String, archive: PathBuf },
13
14 #[error("Command {cmd} exited with code {code:?} stdout: {stdout} stderr: {stderr}")]
15 CommandError {
16 cmd: String,
17 code: Option<i32>,
18 stdout: String,
19 stderr: String,
20 },
21
22 #[error("Failed to write {path} - {error}")]
23 WriteIOError {
24 path: PathBuf,
25 error: std::io::Error,
26 },
27
28 #[error("Failed to read {path} - {error}")]
29 ReadIOError {
30 path: PathBuf,
31 error: std::io::Error,
32 },
33
34 #[error("Failed to parse OctoPrintServer field: {field} {detail:?}")]
35 OctoPrintServerConfigError {
36 field: String,
37 detail: Option<String>,
38 },
39
40 #[error("Failed to handle invalid config value {value:?}")]
41 InvalidValue { value: String },
42
43 #[error(transparent)]
44 FromUtf8Error(#[from] std::string::FromUtf8Error),
45
46 #[error(transparent)]
47 JsonSerError(#[from] serde_json::Error),
48 #[error(transparent)]
49 TomlSerError(#[from] toml::ser::Error),
50 #[error(transparent)]
51 TomlDeError(#[from] toml::de::Error),
52 #[error(transparent)]
53 FigmentError(#[from] figment::error::Error),
54 #[error(transparent)]
55 ZipError(#[from] zip::result::ZipError),
56 #[error(transparent)]
57 IoError(#[from] std::io::Error),
58
59 #[error(transparent)]
60 GitError(#[from] git2::Error),
61
62 #[error(transparent)]
63 TaskJoinError(#[from] tokio::task::JoinError),
64}
65
66#[derive(Error, Debug)]
67pub enum VersionControlledSettingsError {
68 #[error("Failed to write {path} - {error}")]
69 WriteIOError { path: String, error: std::io::Error },
70 #[error("Failed to read {path} - {error}")]
71 ReadIOError { path: String, error: std::io::Error },
72 #[error("Failed to copy {src:?} to {dest:?} - {error}")]
73 CopyIOError {
74 src: PathBuf,
75 dest: PathBuf,
76 error: std::io::Error,
77 },
78 #[error(transparent)]
79 GitError(#[from] git2::Error),
80 #[error(transparent)]
81 ZbusError(#[from] zbus::Error),
82
83 #[error(transparent)]
84 PrintNannySettingsError(#[from] PrintNannySettingsError),
85}