etopay_sdk/wallet/
error.rs1use super::{kdbx::KdbxStorageError, share::ShareError};
2use crate::{backend::error::ApiError, types::error::TypeError, user::error::UserKvStorageError};
3use serde::Serialize;
4
5pub type Result<T> = core::result::Result<T, WalletError>;
7
8#[derive(Debug, Serialize, PartialEq, Clone, Copy)]
9pub enum ErrorKind {
11    MissingPassword,
13    SetRecoveryShare,
15    UseMnemonic,
17}
18
19#[derive(thiserror::Error, Debug)]
21pub enum WalletError {
22    #[error("Password is missing")]
24    MissingPassword,
25
26    #[error("Pin or password incorrect.")]
28    WrongPinOrPassword,
29
30    #[error("Wallet init error: {0:?}")]
32    WalletNotInitialized(ErrorKind),
33
34    #[error("Unauthorized: Missing Access Token")]
36    MissingAccessToken,
37
38    #[error("InvalidTransaction: {0}")]
40    InvalidTransaction(String),
41
42    #[error("KdbxStorage error: {0}")]
44    KdbxStorage(#[from] KdbxStorageError),
45
46    #[error("Type errors: {0}")]
48    Type(#[from] TypeError),
49
50    #[error("User repository error: {0}")]
52    UserRepository(#[from] UserKvStorageError),
53
54    #[error("Share error: {0}")]
56    Share(#[from] ShareError),
57
58    #[error("Bip39 error: {0:?}")]
60    Bip39(#[from] etopay_wallet::bip39::ErrorKind),
61
62    #[error("BackendApi errors: {0}")]
64    BackendApi(#[from] ApiError),
65
66    #[error("WalletImplError: {0}")]
68    WalletImplError(#[from] etopay_wallet::WalletError),
69}