solana_block_decoder/errors/
decode_error.rs1use {
2 solana_sdk::{
3 pubkey::{ParsePubkeyError},
4 signature::ParseSignatureError,
5 hash::{ParseHashError},
6 },
7 std::{
8 error::Error,
9 fmt,
10 },
11};
12
13#[derive(Debug, PartialEq)]
14pub enum DecodeError {
15 InvalidEncoding,
16 InvalidAccountKey,
17 InvalidBlockhash,
18 DecodeFailed,
19 DeserializeFailed,
20 ParseSignatureFailed(ParseSignatureError),
21 ParseHashFailed(ParseHashError),
22 ParsePubkeyFailed(ParsePubkeyError),
23 NotImplemented,
24 InvalidData,
25 UnsupportedEncoding,
26 UnsupportedVersion,
27}
28
29impl fmt::Display for DecodeError {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 match self {
32 DecodeError::InvalidEncoding => write!(f, "Invalid encoding"),
33 DecodeError::DecodeFailed => write!(f, "Decoding failed"),
34 DecodeError::DeserializeFailed => write!(f, "Deserialization failed"),
35 DecodeError::InvalidAccountKey => write!(f, "Invalid account key"),
36 DecodeError::InvalidBlockhash => write!(f, "Invalid blockhash"),
37 DecodeError::ParseSignatureFailed(err) => write!(f, "Failed to parse signature: {}", err),
38 DecodeError::ParseHashFailed(err) => write!(f, "Failed to parse hash: {}", err),
39 DecodeError::ParsePubkeyFailed(err) => write!(f, "Failed to parse pubkey: {}", err),
40 DecodeError::NotImplemented => write!(f, "Not implemented"),
41 DecodeError::InvalidData => write!(f, "Invalid data"),
42 DecodeError::UnsupportedEncoding => write!(f, "Encoding is not supported"),
43 DecodeError::UnsupportedVersion => write!(f, "Transaction version is not supported"),
44 }
45 }
46}
47
48impl Error for DecodeError {}
49
50impl From<ParsePubkeyError> for DecodeError {
51 fn from(err: ParsePubkeyError) -> Self {
52 DecodeError::ParsePubkeyFailed(err)
53 }
54}