-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy patherror.rs
More file actions
63 lines (60 loc) · 2.04 KB
/
error.rs
File metadata and controls
63 lines (60 loc) · 2.04 KB
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
use std::net::AddrParseError;
use defguard_wireguard_rs::{error::WireguardInterfaceError, net::IpAddrParseError};
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("Application config directory error: {0}")]
Config(String),
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
#[error("Migrate error: {0}")]
Migration(#[from] sqlx::migrate::MigrateError),
#[error("Wireguard error: {0}")]
WireguardError(#[from] WireguardInterfaceError),
#[error("WireGuard key error: {0}")]
KeyDecode(#[from] base64::DecodeError),
#[error("IP address/mask error: {0}")]
IpAddrMask(#[from] IpAddrParseError),
#[error("IP address parse error: {0}")]
AddrParse(#[from] AddrParseError),
#[error("Internal error: {0}")]
InternalError(String),
#[error("Failed to parse timestamp")]
Datetime,
#[error("Object not found")]
NotFound,
#[error("Tauri error: {0}")]
Tauri(#[from] tauri::Error),
#[error("Failed to parse str to enum")]
StrumError(#[from] strum::ParseError),
#[error("Required resource not found {0}")]
ResourceNotFound(String),
#[error("Config parse error {0}")]
ConfigParseError(String),
#[error("Command failed: {0}")]
CommandError(String),
#[error("Core is not enterprise")]
CoreNotEnterprise,
#[error("Instance has no config polling token")]
NoToken,
#[error("Failed to lock app state member.")]
StateLockFail,
#[error("Failed to convert value. {0}")]
ConversionError(String),
#[error("JSON error: {0}")]
JsonError(#[from] serde_json::Error),
#[error("HTTP request error: {0}")]
HttpError(String),
#[error("Posture check failed: {0}")]
PostureCheckFailed(String),
}
// we must manually implement serde::Serialize
impl serde::Serialize for Error {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::ser::Serializer,
{
serializer.serialize_str(self.to_string().as_ref())
}
}