bitwarden_importers/importers/onepassword/access/
error.rs1use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum OnePasswordError {
10 #[error("network error: {0}")]
12 Network(String),
13
14 #[error("invalid credentials")]
16 BadCredentials,
17
18 #[error("not found")]
20 NotFound,
21
22 #[error("two-factor authentication required")]
24 TwoFactorRequired,
25
26 #[error("two-factor authentication failed")]
28 TwoFactorFailed,
29
30 #[error("decryption failed")]
32 Decryption,
33
34 #[error("failed to parse server response")]
36 Parse,
37
38 #[error("unsupported: {0}")]
40 Unsupported(String),
41
42 #[error("internal error: {0}")]
44 Internal(String),
45}
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn errors_describe_themselves() {
53 assert_eq!(
54 OnePasswordError::Network("timed out".into()).to_string(),
55 "network error: timed out"
56 );
57 assert_eq!(
58 OnePasswordError::Unsupported("Duo".into()).to_string(),
59 "unsupported: Duo"
60 );
61 assert_eq!(
62 OnePasswordError::BadCredentials.to_string(),
63 "invalid credentials"
64 );
65 }
66}