Print more program error info to user when using CLI (#8098)
This commit is contained in:
@ -1765,6 +1765,12 @@ where
|
|||||||
{
|
{
|
||||||
if let Some(specific_error) = E::decode_custom_error_to_enum(code) {
|
if let Some(specific_error) = E::decode_custom_error_to_enum(code) {
|
||||||
error!("{}::{:?}", E::type_of(), specific_error);
|
error!("{}::{:?}", E::type_of(), specific_error);
|
||||||
|
eprintln!(
|
||||||
|
"Program Error ({}::{:?}): {}",
|
||||||
|
E::type_of(),
|
||||||
|
specific_error,
|
||||||
|
specific_error
|
||||||
|
);
|
||||||
return Err(specific_error.into());
|
return Err(specific_error.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,19 @@ use crate::{
|
|||||||
use num_derive::{FromPrimitive, ToPrimitive};
|
use num_derive::{FromPrimitive, ToPrimitive};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Serialize, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
#[derive(Error, Debug, Serialize, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||||
pub enum SystemError {
|
pub enum SystemError {
|
||||||
|
#[error("an account with the same addreess already exists")]
|
||||||
AccountAlreadyInUse,
|
AccountAlreadyInUse,
|
||||||
|
#[error("account does not have enought lamports to perform the operation")]
|
||||||
ResultWithNegativeLamports,
|
ResultWithNegativeLamports,
|
||||||
|
#[error("cannot assign account to this program id")]
|
||||||
InvalidProgramId,
|
InvalidProgramId,
|
||||||
|
#[error("cannot allocate account data of this length")]
|
||||||
InvalidAccountDataLength,
|
InvalidAccountDataLength,
|
||||||
InvalidSeed,
|
#[error("length of requsted seed is too long")]
|
||||||
MaxSeedLengthExceeded,
|
MaxSeedLengthExceeded,
|
||||||
|
#[error("provided address does not match addressed derived from seed")]
|
||||||
AddressWithSeedMismatch,
|
AddressWithSeedMismatch,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,13 +32,6 @@ impl<T> DecodeError<T> 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)]
|
#[derive(Error, Debug, Clone, PartialEq, FromPrimitive, ToPrimitive)]
|
||||||
pub enum NonceError {
|
pub enum NonceError {
|
||||||
#[error("recent blockhash list is empty")]
|
#[error("recent blockhash list is empty")]
|
||||||
|
@ -66,7 +66,7 @@ pub type Result<T> = result::Result<T, TransactionError>;
|
|||||||
|
|
||||||
impl std::fmt::Display for TransactionError {
|
impl std::fmt::Display for TransactionError {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "transaction error")
|
write!(f, "TransactionError::{:?}", self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user