Migrate to thiserror (#7177)
* Migrate to thiserror * Discourage the use of other modules' Result alias `io::Result` set a bad precedent. Don't import other `Result` aliases.
This commit is contained in:
@@ -15,6 +15,7 @@ serde_derive = "1.0.103"
|
||||
solana-sdk = { path = "../../sdk", version = "0.22.0" }
|
||||
num-derive = "0.3"
|
||||
num-traits = "0.2"
|
||||
thiserror = "1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
solana-runtime = { path = "../../runtime", version = "0.22.0" }
|
||||
|
@@ -5,9 +5,11 @@ use solana_sdk::{
|
||||
pubkey::Pubkey,
|
||||
system_instruction,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
#[derive(Error, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||
pub enum OwnableError {
|
||||
#[error("incorrect error")]
|
||||
IncorrectOwner,
|
||||
}
|
||||
|
||||
@@ -17,19 +19,6 @@ impl<T> DecodeError<T> for OwnableError {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for OwnableError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
OwnableError::IncorrectOwner => "incorrect owner",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
impl std::error::Error for OwnableError {}
|
||||
|
||||
fn initialize_account(account_pubkey: &Pubkey, owner_pubkey: &Pubkey) -> Instruction {
|
||||
let keys = vec![AccountMeta::new(*account_pubkey, false)];
|
||||
Instruction::new(crate::id(), &owner_pubkey, keys)
|
||||
|
Reference in New Issue
Block a user