Custom error decoder (#3783)

automerge
This commit is contained in:
Tyera Eulberg
2019-04-25 11:29:44 -06:00
committed by Grimes
parent b67b0bff05
commit 5a79676b8a
17 changed files with 218 additions and 33 deletions

View File

@@ -1,15 +1,23 @@
use log::*;
use num_derive::FromPrimitive;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::account::KeyedAccount;
use solana_sdk::instruction_processor_utils::DecodeError;
use solana_sdk::pubkey::Pubkey;
#[derive(Serialize, Debug, PartialEq)]
#[derive(Serialize, Debug, PartialEq, FromPrimitive)]
pub enum TokenError {
InvalidArgument,
InsufficentFunds,
NotOwner,
}
impl<T> DecodeError<T> for TokenError {
fn type_of(&self) -> &'static str {
"TokenError"
}
}
impl std::fmt::Display for TokenError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "error")