-
Notifications
You must be signed in to change notification settings - Fork 0
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 (#21)
* program: add custom error codes for executable, ro writes * check in new compute unit benchmarks * drop executable code * check in new compute unit benchmark
- Loading branch information
1 parent
e2024b2
commit 4979b95
Showing
8 changed files
with
158 additions
and
14 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 ConfigError { | ||
/// Instruction modified data of a read-only account. | ||
#[error("Instruction modified data of a read-only account")] | ||
ReadonlyDataModified, | ||
} | ||
|
||
impl PrintProgramError for ConfigError { | ||
fn print<E>(&self) { | ||
msg!(&self.to_string()); | ||
} | ||
} | ||
|
||
impl From<ConfigError> for ProgramError { | ||
fn from(e: ConfigError) -> Self { | ||
ProgramError::Custom(e as u32) | ||
} | ||
} | ||
|
||
impl<T> DecodeError<T> for ConfigError { | ||
fn type_of() -> &'static str { | ||
"ConfigError" | ||
} | ||
} |
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