Skip to main content

trove_core/
error.rs

1use std::path::PathBuf;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("vault file already exists: {0}")]
6    AlreadyExists(PathBuf),
7
8    #[error("vault file not found: {0}")]
9    NotFound(PathBuf),
10
11    #[error("entry not found: {0}")]
12    EntryNotFound(String),
13
14    #[error("invalid password or corrupted vault")]
15    BadPassword,
16
17    #[error("kdbx error: {0}")]
18    Kdbx(String),
19
20    #[error("io error: {0}")]
21    Io(#[from] std::io::Error),
22
23    #[error(
24        "the vault file changed on disk since it was opened: {0}. \
25         Saving would discard whatever changed it — reopen the vault, or save elsewhere."
26    )]
27    StaleWrite(PathBuf),
28
29    #[error("entry has no attachment named {0:?}")]
30    AttachmentNotFound(String),
31
32    #[error("entry already has an attachment named {0:?}")]
33    AttachmentExists(String),
34
35    #[error("invalid entry path: {0}")]
36    InvalidPath(String),
37
38    #[error("group not found: {0}")]
39    GroupNotFound(String),
40
41    #[error("group already exists: {0}")]
42    GroupExists(String),
43
44    #[error("group not empty: {0} (pass --recursive to delete it and its contents)")]
45    GroupNotEmpty(String),
46
47    #[error("entry has no otp field: {0} (set one with `trove add totp`)")]
48    NoTotp(String),
49
50    #[error("totp error: {0}")]
51    Totp(String),
52}