Skip to main content

astroport_vesting/
error.rs

1use cosmwasm_std::{OverflowError, StdError, Uint128};
2use cw_utils::PaymentError;
3use thiserror::Error;
4
5/// This enum describes generator vesting contract errors
6#[derive(Error, Debug, PartialEq)]
7pub enum ContractError {
8    #[error("{0}")]
9    Std(#[from] StdError),
10
11    #[error("{0}")]
12    PaymentError(#[from] PaymentError),
13
14    #[error("Withdrawn amount must not be zero")]
15    ZeroAmountWithdrawal {},
16
17    #[error("Unauthorized")]
18    Unauthorized {},
19
20    #[error("Amount is not available!")]
21    AmountIsNotAvailable {},
22
23    #[error("Vesting schedule error on addr: {0}. Should satisfy: (start < end, end > current_time and start_amount < end_amount)")]
24    VestingScheduleError(String),
25
26    #[error(
27        "Vesting schedule amount error. The total amount should be equal to the received amount."
28    )]
29    VestingScheduleAmountError {},
30
31    #[error("Contract can't be migrated!")]
32    MigrationError {},
33
34    #[error("Failed to withdraw tokens due to multiple active schedules for account {0}")]
35    MultipleActiveSchedules(String),
36
37    #[error("Account {0} has no active vesting schedule")]
38    NoActiveVestingSchedule(String),
39
40    #[error("For account {0} number of schedules exceeds maximum limit")]
41    ExceedSchedulesMaximumLimit(String),
42
43    #[error("Failed to withdraw from active schedule: amount left {0}")]
44    NotEnoughTokens(Uint128),
45}
46
47impl From<OverflowError> for ContractError {
48    fn from(o: OverflowError) -> Self {
49        StdError::from(o).into()
50    }
51}