diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 2842aa080a..e5f3e1df52 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1765,6 +1765,12 @@ where { if let Some(specific_error) = E::decode_custom_error_to_enum(code) { error!("{}::{:?}", E::type_of(), specific_error); + eprintln!( + "Program Error ({}::{:?}): {}", + E::type_of(), + specific_error, + specific_error + ); return Err(specific_error.into()); } } diff --git a/sdk/src/system_instruction.rs b/sdk/src/system_instruction.rs index e69f4a0005..aa5daae3fd 100644 --- a/sdk/src/system_instruction.rs +++ b/sdk/src/system_instruction.rs @@ -10,14 +10,19 @@ use crate::{ use num_derive::{FromPrimitive, ToPrimitive}; use thiserror::Error; -#[derive(Serialize, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)] +#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)] pub enum SystemError { + #[error("an account with the same addreess already exists")] AccountAlreadyInUse, + #[error("account does not have enought lamports to perform the operation")] ResultWithNegativeLamports, + #[error("cannot assign account to this program id")] InvalidProgramId, + #[error("cannot allocate account data of this length")] InvalidAccountDataLength, - InvalidSeed, + #[error("length of requsted seed is too long")] MaxSeedLengthExceeded, + #[error("provided address does not match addressed derived from seed")] AddressWithSeedMismatch, } @@ -27,13 +32,6 @@ impl DecodeError for SystemError { } } -impl std::fmt::Display for SystemError { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "error") - } -} -impl std::error::Error for SystemError {} - #[derive(Error, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)] pub enum NonceError { #[error("recent blockhash list is empty")] diff --git a/sdk/src/transaction.rs b/sdk/src/transaction.rs index 6cae3704a4..27a100f66f 100644 --- a/sdk/src/transaction.rs +++ b/sdk/src/transaction.rs @@ -66,7 +66,7 @@ pub type Result = result::Result; impl std::fmt::Display for TransactionError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "transaction error") + write!(f, "TransactionError::{:?}", self) } }