-
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 readonly writes (#43)
- Loading branch information
1 parent
cf11c00
commit 8be62dd
Showing
8 changed files
with
151 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
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,37 @@ | ||
//! 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 modified data of a read-only account. | ||
#[error("Instruction modified data of a read-only account")] | ||
ReadonlyDataModified = 10, // Avoid collisions with System. | ||
} | ||
|
||
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