simple_nft/
error.rs

1use cosmwasm_std::{Coin, StdError};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ContractError {
6    #[error("{0}")]
7    Std(#[from] StdError),
8
9    /// Only authorized entities are allowed to execute.
10    #[error("Unauthorized")]
11    Unauthorized,
12
13    /// The approvals has expired.
14    #[error("Cannot set approval that is already expired")]
15    Expired,
16
17    /// operator has already been approved previously.
18    #[error("{operator} has already been approved")]
19    OperatorApproved { operator: String },
20
21    /// No approval found for given address.
22    #[error("Approval not found for: {operator}")]
23    ApprovalNotFound { operator: String },
24
25    /// Supplied token id is invalid.
26    #[error("token_id: {token_id} does not exist")]
27    InvalidToken { token_id: u64 },
28
29    /// Amount sent in not equal to the price of the NFT.
30    #[error("Invalid amount. Expected {val:?} received {funds:?}")]
31    InvalidAmount { val: Coin, funds: Coin },
32
33    /// Any other error not which has not been covered.
34    #[error("Following error occured: {val:?}")]
35    CustomError { val: String },
36    // Add any other custom errors you like here.
37    // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details.
38}