solana_gateway/
error.rs

1//! Error types
2
3use {
4    num_derive::FromPrimitive,
5    solana_program::{decode_error::DecodeError, program_error::ProgramError},
6    thiserror::Error,
7};
8
9/// Errors that may be returned by the program.
10#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
11pub enum GatewayError {
12    /// The gatekeeper listed in the gateway token is not accepted
13    #[error("The gatekeeper listed in the gateway token is not accepted")]
14    IncorrectGatekeeper,
15
16    /// The gateway token's owner is not the account placing the order
17    #[error("The gateway token's owner is not the account placing the order")]
18    InvalidOwner,
19
20    /// The gateway token account is not of the correct type
21    #[error("The gateway token account is not of the correct type")]
22    InvalidToken,
23
24    /// The gateway token was revoked
25    #[error("The gateway token was revoked")]
26    TokenRevoked,
27
28    /// The gateway token was expected to be revoked, but was not
29    #[error("The gateway token was expected to be revoked, but was not")]
30    ExpectedRevokedToken,
31
32    /// The gatway token could not be changed into the requested state
33    #[error("Invalid state change")]
34    InvalidStateChange,
35
36    /// The account is not owned by the gateway program
37    #[error("The account is not owned by the gateway program")]
38    IncorrectProgramId,
39
40    /// The gateway token has expired
41    #[error("The gateway token has expired")]
42    TokenExpired,
43
44    /// An error occurred when burning the token
45    #[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}