1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
use std::path::PathBuf;
use thiserror::Error;
use printnanny_api_client::apis::alert_settings_api;
use printnanny_api_client::apis::auth_api;
use printnanny_api_client::apis::config_api;
use printnanny_api_client::apis::devices_api;
use printnanny_api_client::apis::octoprint_api;
use printnanny_api_client::apis::users_api;
use printnanny_api_client::apis::Error as ApiError;
#[derive(Error, Debug)]
pub enum PrintNannyConfigError {
#[error("Failed to read {path:?}. Please download a license from https://printnanny.ai/dashboard/ and save to {path:?}")]
LicenseMissing { path: String },
#[error("Command {cmd} exited with code {code:?} stdout: {stdout} stderr: {stderr}")]
CommandError {
cmd: String,
code: Option<i32>,
stdout: String,
stderr: String,
},
#[error("Failed to parse OctoPrintServer field: {field} {detail:?}")]
OctoPrintServerConfigError {
field: String,
detail: Option<String>,
},
#[error("Failed to handle invalid config value {value:?}")]
InvalidValue { value: String },
#[error("Refusing to overwrite existing keypair at {path:?}.")]
KeypairExists { path: PathBuf },
#[error(transparent)]
IOError(#[from] std::io::Error),
#[error(transparent)]
OpenSSLError(#[from] openssl::error::ErrorStack),
#[error(transparent)]
JsonSerError(#[from] serde_json::Error),
#[error(transparent)]
TomlSerError(#[from] toml::ser::Error),
#[error(transparent)]
FigmentError(#[from] figment::error::Error),
}
#[derive(Error, Debug)]
pub enum ServiceError {
#[error(transparent)]
JsonSerError(#[from] serde_json::Error),
#[error(transparent)]
TomlSerError(#[from] toml::ser::Error),
#[error(transparent)]
AlertSettingsGetOrCreateRetrieveError(
#[from] ApiError<alert_settings_api::AlertSettingsGetOrCreateRetrieveError>,
),
#[error(transparent)]
ApiConfigRetreiveError(#[from] ApiError<config_api::ApiConfigRetreiveError>),
#[error(transparent)]
AuthTokenCreateError(#[from] ApiError<auth_api::AuthTokenCreateError>),
#[error(transparent)]
AuthEmailCreateError(#[from] ApiError<auth_api::AuthEmailCreateError>),
#[error(transparent)]
CloudiotDeviceUpdateOrCreateError(
#[from] ApiError<devices_api::CloudiotDeviceUpdateOrCreateError>,
),
#[error(transparent)]
DevicesCreateError(#[from] ApiError<devices_api::DevicesCreateError>),
#[error(transparent)]
DevicesRetrieveError(#[from] ApiError<devices_api::DevicesRetrieveError>),
#[error(transparent)]
DevicesPartialUpdateError(#[from] ApiError<devices_api::DevicesPartialUpdateError>),
#[error(transparent)]
DevicesRetrieveHostnameError(#[from] ApiError<devices_api::DevicesRetrieveHostnameError>),
#[error(transparent)]
SystemInfoCreateError(#[from] ApiError<devices_api::DevicesSystemInfoCreateError>),
#[error(transparent)]
SystemInfoUpdateOrCreateError(#[from] ApiError<devices_api::SystemInfoUpdateOrCreateError>),
#[error(transparent)]
OctoprintServerUpdateOrCreateError(
#[from] ApiError<octoprint_api::OctoprintServerUpdateOrCreateError>,
),
#[error(transparent)]
PublicKeyUpdateOrCreate(#[from] ApiError<devices_api::PublicKeyUpdateOrCreateError>),
#[error(transparent)]
FromUtf8Error(#[from] std::string::FromUtf8Error),
#[error(transparent)]
UsersRetrieveError(#[from] ApiError<users_api::UsersMeRetrieveError>),
#[error(transparent)]
Utf8Error(#[from] std::str::Utf8Error),
#[error("License fingerprint mismatch (expected {expected:?}, found {active:?})")]
InvalidLicense { expected: String, active: String },
#[error("Failed to fingerprint {path:?} got stderr {stderr:?}")]
FingerprintError { path: PathBuf, stderr: String },
#[error(transparent)]
ProcError(#[from] procfs::ProcError),
#[error(transparent)]
FigmentError(#[from] figment::Error),
#[error(transparent)]
SysInfoError(#[from] sys_info::Error),
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
PrintNannyConfigError(#[from] PrintNannyConfigError),
#[error("Setup incomplete, failed to read {field:?} {detail:?}")]
SetupIncomplete {
detail: Option<String>,
field: String,
},
}