1use {
4 num_derive::FromPrimitive,
5 solana_program::{decode_error::DecodeError, program_error::ProgramError},
6 thiserror::Error,
7};
8
9#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
11pub enum GatewayError {
12 #[error("The gatekeeper listed in the gateway token is not accepted")]
14 IncorrectGatekeeper,
15
16 #[error("The gateway token's owner is not the account placing the order")]
18 InvalidOwner,
19
20 #[error("The gateway token account is not of the correct type")]
22 InvalidToken,
23
24 #[error("The gateway token was revoked")]
26 TokenRevoked,
27
28 #[error("The gateway token was expected to be revoked, but was not")]
30 ExpectedRevokedToken,
31
32 #[error("Invalid state change")]
34 InvalidStateChange,
35
36 #[error("The account is not owned by the gateway program")]
38 IncorrectProgramId,
39
40 #[error("The gateway token has expired")]
42 TokenExpired,
43
44 #[error("An error occurred when burning the token")]
46 BurnError,
47}
48impl From<GatewayError> for ProgramError {
49 fn from(e: GatewayError) -> Self {
50 ProgramError::Custom(e as u32)
51 }
52}
53impl<T> DecodeError<T> for GatewayError {
54 fn type_of() -> &'static str {
55 "Gateway Error"
56 }
57}