1pub use bitwarden_api_base::Error as ApiError;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8#[error("The client is not authenticated or the session has expired")]
9pub struct NotAuthenticatedError;
10
11#[derive(Debug, Error, serde::Serialize, serde::Deserialize, Clone)]
13#[error("The client user ID is already set")]
14pub struct UserIdAlreadySetError;
15
16#[derive(Debug, Error)]
18#[error("The response received was missing a required field: {0}")]
19pub struct MissingFieldError(pub &'static str);
20
21#[derive(Debug, thiserror::Error)]
23#[error("Wrong password")]
24pub struct WrongPasswordError;
25
26#[derive(Debug, thiserror::Error)]
28#[error("Missing private key")]
29pub struct MissingPrivateKeyError;
30
31#[macro_export]
36macro_rules! require {
37 ($val:expr) => {
38 match $val {
39 Some(val) => val,
40 None => return Err($crate::MissingFieldError(stringify!($val)).into()),
41 }
42 };
43}