pub enum VaultError {
BadRequest(String),
PermissionDenied(String),
NotFound {
path: String,
},
Stale(String),
Standby(String),
Sealed(String),
Unexpected {
status: u16,
message: String,
},
Transport(String),
Malformed {
path: String,
message: String,
},
}Expand description
A failure from the secret store.
Variants§
BadRequest(String)
400 — the request itself was wrong.
PermissionDenied(String)
403 — no token, an expired one, or one without the policy for this path.
Vault does not distinguish “expired” from “not allowed”, so neither can this. The message says so rather than guessing.
NotFound
404 — no such path, or nothing stored at it.
Worth its own variant because it is usually not an error: reading a secret that may not be there yet is an ordinary thing to do.
Stale(String)
412 — a standby node has not caught up with the value being asked for. Retrying against the active node is the fix, and it usually works.
Standby(String)
429 — a standby that will not serve this request at all.
Sealed(String)
503 — the store is sealed or unavailable. Nothing the caller does helps; somebody has to unseal it.
Unexpected
Anything else, including a body that did not parse.
Transport(String)
The request never reached the server.
Malformed
The store answered successfully, with something this driver cannot read.
Distinct from every variant above, which are the store saying no. This one is the store saying yes and handing over a shape we did not expect — a KV version 1 mount read as version 2, or credentials with no password in them. Retrying cannot help, and treating it as a plain failure would hide the one detail that explains it: which path, and what was wrong.
Implementations§
Source§impl VaultError
impl VaultError
Sourcepub fn from_response(status: u16, path: &str, body: &str) -> VaultError
pub fn from_response(status: u16, path: &str, body: &str) -> VaultError
Build from a status code and whatever body came with it.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether trying again, unchanged, could plausibly work.
A sealed store is deliberately not retryable: unsealing is a human action that takes minutes at best, and hammering the endpoint until it happens only buries the log line that would have explained the outage.
Sourcepub fn needs_new_token(&self) -> bool
pub fn needs_new_token(&self) -> bool
Whether re-authenticating and trying again could work.
pub fn is_not_found(&self) -> bool
Trait Implementations§
Source§impl Clone for VaultError
impl Clone for VaultError
Source§impl Debug for VaultError
impl Debug for VaultError
Source§impl Display for VaultError
impl Display for VaultError
impl Eq for VaultError
Source§impl Error for VaultError
impl Error for VaultError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()