pyth_client/
error.rs

1use num_derive::FromPrimitive;
2use solana_program::program_error::ProgramError;
3use thiserror::Error;
4
5/// Errors that may be returned by Pyth.
6#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
7pub enum PythError {
8  // 0
9  /// Invalid account data -- either insufficient data, or incorrect magic number
10  #[error("Failed to convert account into a Pyth account")]
11  InvalidAccountData,
12  /// Wrong version number
13  #[error("Incorrect version number for Pyth account")]
14  BadVersionNumber,
15  /// Tried reading an account with the wrong type, e.g., tried to read
16  /// a price account as a product account.
17  #[error("Incorrect account type")]
18  WrongAccountType,
19}
20
21impl From<PythError> for ProgramError {
22  fn from(e: PythError) -> Self {
23    ProgramError::Custom(e as u32)
24  }
25}