sos_platform_authenticator/
error.rs1use http::StatusCode;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
6pub enum Error {
7 #[error("keyring entry not found")]
9 NoKeyringEntry,
10
11 #[error("unauthorized")]
15 Unauthorized,
16
17 #[error("forbidden")]
19 Forbidden,
20
21 #[cfg(all(not(target_os = "android"), not(target_os = "macos")))]
23 #[error(transparent)]
24 Keyring(#[from] keyring::Error),
25
26 #[error(transparent)]
28 Utf8(#[from] std::str::Utf8Error),
29
30 #[cfg(target_os = "macos")]
32 #[error(transparent)]
33 SecurityFramework(#[from] security_framework::base::Error),
34}
35
36impl From<&Error> for StatusCode {
37 fn from(value: &Error) -> Self {
38 match value {
39 Error::NoKeyringEntry => StatusCode::NOT_FOUND,
40 Error::Unauthorized => StatusCode::UNAUTHORIZED,
41 Error::Forbidden => StatusCode::FORBIDDEN,
42 _ => StatusCode::INTERNAL_SERVER_ERROR,
43 }
44 }
45}