pyth_sdk_cw/
error.rs

1use {
2    cosmwasm_std::StdError,
3    thiserror::Error,
4};
5
6#[derive(Error, Debug)]
7pub enum PythContractError {
8    /// Message sender not permitted to execute this operation
9    #[error("PermissionDenied")]
10    PermissionDenied,
11
12    /// Wrapped asset not found in the registry
13    #[error("PriceFeedNotFound")]
14    PriceFeedNotFound,
15
16    /// Message emitter is not an accepted data source.
17    #[error("InvalidUpdateMessageEmitter")]
18    InvalidUpdateEmitter,
19
20    /// Message payload cannot be deserialized to a batch attestation
21    #[error("InvalidUpdatePayload")]
22    InvalidUpdatePayload,
23
24    /// Data source does not exists error (on removing data source)
25    #[error("DataSourceDoesNotExists")]
26    DataSourceDoesNotExists,
27
28    /// Data source already exists error (on adding data source)
29    #[error("DataSourceAlreadyExists")]
30    DataSourceAlreadyExists,
31
32    /// Message emitter is not an accepted source of governance instructions.
33    #[error("InvalidGovernanceEmitter")]
34    InvalidGovernanceEmitter,
35
36    /// Message payload cannot be deserialized as a valid governance instruction.
37    #[error("InvalidGovernancePayload")]
38    InvalidGovernancePayload,
39
40    /// The sequence number of the governance message is too old.
41    #[error("OldGovernanceMessage")]
42    OldGovernanceMessage,
43
44    /// The governance source index it not valid.
45    #[error("OldGovernanceMessage")]
46    InvalidGovernanceSourceIndex,
47
48    /// The message did not include a sufficient fee.
49    #[error("InsufficientFee")]
50    InsufficientFee,
51
52    /// The message did not include a sufficient fee.
53    #[error("InvalidFeeDenom")]
54    InvalidFeeDenom { denom: String },
55}
56
57impl From<PythContractError> for StdError {
58    fn from(other: PythContractError) -> StdError {
59        StdError::GenericErr {
60            msg: format!("{other}"),
61        }
62    }
63}