mantra_claimdrop_std/
error.rs1use cosmwasm_std::{ConversionOverflowError, Decimal, OverflowError, StdError};
2use cw_migrate_error_derive::cw_migrate_invalid_version_error;
3use cw_ownable::OwnershipError;
4use cw_utils::PaymentError;
5use thiserror::Error;
6
7#[cw_migrate_invalid_version_error]
8#[derive(Error, Debug)]
9pub enum ContractError {
10 #[error("{0}")]
11 Std(#[from] StdError),
12
13 #[error("Semver parsing error: {0}")]
14 SemVer(String),
15
16 #[error("{0}")]
17 OwnershipError(#[from] OwnershipError),
18
19 #[error("{0}")]
20 OverflowError(#[from] OverflowError),
21
22 #[error("{0}")]
23 ConversionOverflowError(#[from] ConversionOverflowError),
24
25 #[error("{0}")]
26 PaymentError(#[from] PaymentError),
27
28 #[error("Invalid distribution percentage, expected: {expected}, actual: {actual}")]
29 InvalidDistributionPercentage { expected: Decimal, actual: Decimal },
30
31 #[error("Invalid distribution percentage, cannot be zero")]
32 ZeroDistributionPercentage,
33
34 #[error("Invalid campaign parameter: {param} - {reason}")]
35 InvalidCampaignParam { param: String, reason: String },
36
37 #[error("Claim amount exceeds the maximum claimable amount")]
38 ExceededMaxClaimAmount,
39
40 #[error("Campaign error: {reason}")]
41 CampaignError { reason: String },
42
43 #[error("Invalid distribution times, start time: {start_time}, end time: {end_time}")]
44 InvalidDistributionTimes { start_time: u64, end_time: u64 },
45
46 #[error("Invalid start distribution time, start time: {start_time}, campaign start time: {campaign_start_time}. The start time needs to be in the future.")]
47 InvalidStartDistributionTime {
48 start_time: u64,
49 campaign_start_time: u64,
50 },
51
52 #[error("Invalid end distribution time, end time: {end_time}, campaign_end_time: {campaign_end_time}. The distribution end time needs to be less or equal to the campaign's end time.")]
53 InvalidEndDistributionTime {
54 end_time: u64,
55 campaign_end_time: u64,
56 },
57
58 #[error("There's nothing to claim for the given address")]
59 NothingToClaim,
60
61 #[error("No allocation found for address: {address}")]
62 NoAllocationFound { address: String },
63
64 #[error("The current address already has an allocation: {address}")]
65 AllocationAlreadyExists { address: String },
66
67 #[error("Address is blacklisted")]
68 AddressBlacklisted,
69
70 #[error("Invalid claim amount: {reason}")]
71 InvalidClaimAmount { reason: String },
72
73 #[error("Invalid input: {reason}")]
74 InvalidInput { reason: String },
75
76 #[error("Batch size limit exceeded: {actual}, maximum allowed: {max}")]
77 BatchSizeLimitExceeded { actual: usize, max: usize },
78
79 #[error("Unauthorized")]
80 Unauthorized,
81}
82
83impl From<semver::Error> for ContractError {
84 fn from(err: semver::Error) -> Self {
85 Self::SemVer(err.to_string())
86 }
87}