aboutsummaryrefslogtreecommitdiffstats
path: root/src/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs99
1 files changed, 48 insertions, 51 deletions
diff --git a/src/error.rs b/src/error.rs
index cd85c02..3576aa1 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -1,186 +1,183 @@
-#[derive(Debug, snafu::Snafu)]
-#[snafu(visibility = "pub")]
+#[derive(thiserror::Error, Debug)]
pub enum Error {
- #[snafu(display("email address not set"))]
+ #[error("email address not set")]
ConfigMissingEmail,
- #[snafu(display("failed to create block mode decryptor"))]
+ #[error("failed to create block mode decryptor")]
CreateBlockMode {
source: block_modes::InvalidKeyIvLength,
},
- #[snafu(display("failed to create directory at {}", file.display()))]
+ #[error("failed to create directory at {}", .file.display())]
CreateDirectory {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to decrypt"))]
+ #[error("failed to decrypt")]
Decrypt { source: block_modes::BlockModeError },
- #[snafu(display("failed to parse pinentry output ({:?})", out))]
+ #[error("failed to parse pinentry output ({out:?})")]
FailedToParsePinentry { out: String },
- #[snafu(display(
- "failed to run editor {}: {:?}",
- editor.to_string_lossy(),
- res
- ))]
+ #[error(
+ "failed to run editor {}: {res:?}",
+ .editor.to_string_lossy(),
+ )]
FailedToRunEditor {
editor: std::path::PathBuf,
res: std::process::ExitStatus,
},
- #[snafu(display("failed to expand with hkdf"))]
+ #[error("failed to expand with hkdf")]
HkdfExpand,
- #[snafu(display("{}", message))]
+ #[error("{message}")]
IncorrectPassword { message: String },
- #[snafu(display("invalid base64"))]
+ #[error("invalid base64")]
InvalidBase64 { source: base64::DecodeError },
- #[snafu(display("invalid cipherstring: {}", reason))]
+ #[error("invalid cipherstring: {reason}")]
InvalidCipherString { reason: String },
- #[snafu(display(
- "invalid value for ${}: {}",
- var,
- editor.to_string_lossy()
- ))]
+ #[error(
+ "invalid value for ${var}: {}",
+ .editor.to_string_lossy()
+ )]
InvalidEditor {
var: String,
editor: std::ffi::OsString,
},
- #[snafu(display("invalid mac"))]
+ #[error("invalid mac")]
InvalidMac,
- #[snafu(display("invalid two factor provider type: {}", ty))]
+ #[error("invalid two factor provider type: {ty}")]
InvalidTwoFactorProvider { ty: String },
- #[snafu(display("failed to parse JSON"))]
+ #[error("failed to parse JSON")]
JSON {
source: serde_path_to_error::Error<serde_json::Error>,
},
- #[snafu(display("failed to load config from {}", file.display()))]
+ #[error("failed to load config from {}", .file.display())]
LoadConfig {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to load config from {}", file.display()))]
+ #[error("failed to load config from {}", .file.display())]
LoadConfigAsync {
source: tokio::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to load config from {}", file.display()))]
+ #[error("failed to load config from {}", .file.display())]
LoadConfigJson {
source: serde_json::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to load db from {}", file.display()))]
+ #[error("failed to load db from {}", .file.display())]
LoadDb {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to load db from {}", file.display()))]
+ #[error("failed to load db from {}", .file.display())]
LoadDbAsync {
source: tokio::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to load db from {}", file.display()))]
+ #[error("failed to load db from {}", .file.display())]
LoadDbJson {
source: serde_json::Error,
file: std::path::PathBuf,
},
- #[snafu(display("openssl error"))]
+ #[error("openssl error")]
OpenSSL { source: openssl::error::ErrorStack },
- #[snafu(display("failed to parse match type {}", s))]
+ #[error("failed to parse match type {s}")]
ParseMatchType { s: String },
- #[snafu(display("pbkdf2 requires at least 1 iteration (got 0)"))]
+ #[error("pbkdf2 requires at least 1 iteration (got 0)")]
Pbkdf2ZeroIterations,
- #[snafu(display("pinentry cancelled"))]
+ #[error("pinentry cancelled")]
PinentryCancelled,
- #[snafu(display("pinentry error: {}", error))]
+ #[error("pinentry error: {error}")]
PinentryErrorMessage { error: String },
- #[snafu(display("error reading pinentry output"))]
+ #[error("error reading pinentry output")]
PinentryReadOutput { source: tokio::io::Error },
- #[snafu(display("error waiting for pinentry to exit"))]
+ #[error("error waiting for pinentry to exit")]
PinentryWait { source: tokio::io::Error },
- #[snafu(display("failed to remove db at {}", file.display()))]
+ #[error("failed to remove db at {}", .file.display())]
RemoveDb {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("api request returned error: {}", status))]
+ #[error("api request returned error: {status}")]
RequestFailed { status: u16 },
- #[snafu(display("api request unauthorized"))]
+ #[error("api request unauthorized")]
RequestUnauthorized,
- #[snafu(display("error making api request"))]
+ #[error("error making api request")]
Reqwest { source: reqwest::Error },
- #[snafu(display("failed to save config to {}", file.display()))]
+ #[error("failed to save config to {}", .file.display())]
SaveConfig {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to save config to {}", file.display()))]
+ #[error("failed to save config to {}", .file.display())]
SaveConfigJson {
source: serde_json::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to save db to {}", file.display()))]
+ #[error("failed to save db to {}", .file.display())]
SaveDb {
source: std::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to save db to {}", file.display()))]
+ #[error("failed to save db to {}", .file.display())]
SaveDbAsync {
source: tokio::io::Error,
file: std::path::PathBuf,
},
- #[snafu(display("failed to save db to {}", file.display()))]
+ #[error("failed to save db to {}", .file.display())]
SaveDbJson {
source: serde_json::Error,
file: std::path::PathBuf,
},
- #[snafu(display("error spawning pinentry"))]
+ #[error("error spawning pinentry")]
Spawn { source: tokio::io::Error },
- #[snafu(display("cipherstring type {} too old\n\nPlease rotate your account encryption key (https://bitwarden.com/help/article/account-encryption-key/) and try again.", ty))]
+ #[error("cipherstring type {ty} too old\n\nPlease rotate your account encryption key (https://bitwarden.com/help/article/account-encryption-key/) and try again.")]
TooOldCipherStringType { ty: String },
- #[snafu(display("two factor required"))]
+ #[error("two factor required")]
TwoFactorRequired {
providers: Vec<crate::api::TwoFactorProviderType>,
},
- #[snafu(display("unimplemented cipherstring type: {}", ty))]
+ #[error("unimplemented cipherstring type: {ty}")]
UnimplementedCipherStringType { ty: String },
- #[snafu(display("error writing to pinentry stdin"))]
+ #[error("error writing to pinentry stdin")]
WriteStdin { source: tokio::io::Error },
}