Skip to main content

tsafe_bitwarden/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur during a Bitwarden pull operation.
4#[derive(Debug, Error)]
5pub enum BitwError {
6    /// The `bw` CLI binary was not found on `PATH`.
7    #[error(
8        "Bitwarden CLI `bw` not found on PATH — install it from https://bitwarden.com/help/cli/"
9    )]
10    CliNotFound,
11
12    /// `bw login` exited with a non-zero status.
13    #[error("bw login failed (exit {status}): {stderr}")]
14    LoginFailed { status: i32, stderr: String },
15
16    /// `bw unlock` exited with a non-zero status.
17    #[error("bw unlock failed (exit {status}): {stderr}")]
18    UnlockFailed { status: i32, stderr: String },
19
20    /// `bw lock` (cleanup) exited with a non-zero status — non-fatal, logged only.
21    #[error("bw lock failed (exit {status}): {stderr}")]
22    LockFailed { status: i32, stderr: String },
23
24    /// `bw list items` exited with a non-zero status.
25    #[error("bw list items failed (exit {status}): {stderr}")]
26    ListFailed { status: i32, stderr: String },
27
28    /// The session token output from `bw unlock` could not be extracted.
29    #[error("could not extract BW_SESSION token from `bw unlock` output")]
30    SessionTokenMissing,
31
32    /// The JSON output from `bw list items` could not be parsed.
33    #[error("failed to parse `bw list items` JSON: {0}")]
34    ParseError(String),
35
36    /// A required configuration value (client_id, client_secret, password env) is missing.
37    #[error("Bitwarden configuration error: {0}")]
38    Config(String),
39}