use {
num_derive::FromPrimitive,
solana_program::{decode_error::DecodeError, program_error::ProgramError},
thiserror::Error,
};
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum GatewayError {
#[error("The gatekeeper listed in the gateway token is not accepted")]
IncorrectGatekeeper,
#[error("The gateway token's owner is not the account placing the order")]
InvalidOwner,
#[error("The gateway token account is not of the correct type")]
InvalidToken,
#[error("The gateway token is a session token, but has a lamport balance that would make it exceed the lifetime of the transaction.")]
InvalidSessionToken,
#[error("The gateway token was revoked")]
TokenRevoked,
#[error("The gateway token was expected to be revoked, but was not")]
ExpectedRevokedToken,
#[error("Invalid state change")]
InvalidStateChange,
#[error("The account is not owned by the gateway program")]
IncorrectProgramId,
#[error("The gateway token has expired")]
TokenExpired,
#[error("The passed gatekeeper account is not valid")]
InvalidGatekeeperAccount,
}
impl From<GatewayError> for ProgramError {
fn from(e: GatewayError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for GatewayError {
fn type_of() -> &'static str {
"Gateway Error"
}
}