-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
program: add custom error codes for executable, ro writes
- Loading branch information
1 parent
3821e81
commit 8e59e37
Showing
7 changed files
with
178 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! Program error types. | ||
use { | ||
num_derive::FromPrimitive, | ||
solana_program::{ | ||
decode_error::DecodeError, | ||
msg, | ||
program_error::{PrintProgramError, ProgramError}, | ||
}, | ||
thiserror::Error, | ||
}; | ||
|
||
/// Errors that can be returned by the Config program. | ||
#[derive(Error, Clone, Debug, Eq, PartialEq, FromPrimitive)] | ||
pub enum AddressLookupTableError { | ||
/// Instruction changed executable account's data. | ||
#[error("Instruction changed executable account's data")] | ||
ExecutableDataModified = 10, // Avoid collisions with SystemError from CPI. | ||
/// Instruction modified data of a read-only account. | ||
#[error("Instruction modified data of a read-only account")] | ||
ReadonlyDataModified, | ||
} | ||
|
||
impl PrintProgramError for AddressLookupTableError { | ||
fn print<E>(&self) { | ||
msg!(&self.to_string()); | ||
} | ||
} | ||
|
||
impl From<AddressLookupTableError> for ProgramError { | ||
fn from(e: AddressLookupTableError) -> Self { | ||
ProgramError::Custom(e as u32) | ||
} | ||
} | ||
|
||
impl<T> DecodeError<T> for AddressLookupTableError { | ||
fn type_of() -> &'static str { | ||
"AddressLookupTableError" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters