bvs_vault_base/
error.rs

1use cosmwasm_std::StdError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum VaultError {
6    #[error("{0}")]
7    Std(#[from] StdError),
8
9    #[error("Unauthorized: {msg}")]
10    Unauthorized { msg: String },
11
12    #[error("Vault is not whitelisted")]
13    NotWhitelisted {},
14
15    #[error("Vault is validating, withdrawal must be queued")]
16    Validating {},
17
18    #[error("Insufficient: {msg}")]
19    Insufficient { msg: String },
20
21    #[error("Zero: {msg}")]
22    Zero { msg: String },
23
24    #[error("Locked: {msg}")]
25    Locked { msg: String },
26}
27
28impl VaultError {
29    pub fn unauthorized(msg: impl Into<String>) -> Self {
30        VaultError::Unauthorized { msg: msg.into() }
31    }
32
33    pub fn insufficient(msg: impl Into<String>) -> Self {
34        VaultError::Insufficient { msg: msg.into() }
35    }
36
37    pub fn zero(msg: impl Into<String>) -> Self {
38        VaultError::Zero { msg: msg.into() }
39    }
40
41    pub fn locked(msg: impl Into<String>) -> Self {
42        VaultError::Locked { msg: msg.into() }
43    }
44}