|
| 1 | +use light_account_checks::error::AccountError; |
1 | 2 | use light_hasher::HasherError; |
2 | 3 | pub use light_sdk_types::error::LightSdkTypesError; |
3 | 4 | use light_zero_copy::errors::ZeroCopyError; |
@@ -68,12 +69,20 @@ pub enum LightSdkError { |
68 | 69 | MetaCloseInputIsNone, |
69 | 70 | #[error("CPI accounts index out of bounds: {0}")] |
70 | 71 | CpiAccountsIndexOutOfBounds(usize), |
| 72 | + #[error("Invalid CPI context account")] |
| 73 | + InvalidCpiContextAccount, |
| 74 | + #[error("Invalid sol pool pda account")] |
| 75 | + InvalidSolPoolPdaAccount, |
| 76 | + #[error("CpigAccounts accounts slice starts with an invalid account. It should start with LightSystemProgram SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7.")] |
| 77 | + InvalidCpiAccountsOffset, |
71 | 78 | #[error(transparent)] |
72 | 79 | Hasher(#[from] HasherError), |
73 | 80 | #[error(transparent)] |
74 | 81 | ZeroCopy(#[from] ZeroCopyError), |
75 | 82 | #[error("Program error: {0:?}")] |
76 | 83 | ProgramError(ProgramError), |
| 84 | + #[error(transparent)] |
| 85 | + AccountError(#[from] AccountError), |
77 | 86 | } |
78 | 87 |
|
79 | 88 | impl From<ProgramError> for LightSdkError { |
@@ -111,6 +120,10 @@ impl From<LightSdkTypesError> for LightSdkError { |
111 | 120 | LightSdkTypesError::CpiAccountsIndexOutOfBounds(index) => { |
112 | 121 | LightSdkError::CpiAccountsIndexOutOfBounds(index) |
113 | 122 | } |
| 123 | + LightSdkTypesError::InvalidCpiContextAccount => LightSdkError::InvalidCpiContextAccount, |
| 124 | + LightSdkTypesError::InvalidSolPoolPdaAccount => LightSdkError::InvalidSolPoolPdaAccount, |
| 125 | + LightSdkTypesError::AccountError(e) => LightSdkError::AccountError(e), |
| 126 | + LightSdkTypesError::InvalidCpiAccountsOffset => LightSdkError::InvalidCpiAccountsOffset, |
114 | 127 | } |
115 | 128 | } |
116 | 129 | } |
@@ -148,9 +161,13 @@ impl From<LightSdkError> for u32 { |
148 | 161 | LightSdkError::MetaCloseAddressIsNone => 16028, |
149 | 162 | LightSdkError::MetaCloseInputIsNone => 16029, |
150 | 163 | LightSdkError::CpiAccountsIndexOutOfBounds(_) => 16031, |
| 164 | + LightSdkError::InvalidCpiContextAccount => 16032, |
| 165 | + LightSdkError::InvalidSolPoolPdaAccount => 16033, |
| 166 | + LightSdkError::InvalidCpiAccountsOffset => 16034, |
151 | 167 | LightSdkError::Hasher(e) => e.into(), |
152 | 168 | LightSdkError::ZeroCopy(e) => e.into(), |
153 | 169 | LightSdkError::ProgramError(e) => u64::from(e) as u32, |
| 170 | + LightSdkError::AccountError(e) => e.into(), |
154 | 171 | } |
155 | 172 | } |
156 | 173 | } |
0 commit comments