gmsol_decode/error.rs
1/// Decode Error.
2#[derive(Debug, thiserror::Error)]
3pub enum DecodeError {
4 /// Custom Error.
5 #[error("custom: {0}")]
6 Custom(String),
7 /// Invalid Type.
8 #[error("invalid type: {0}")]
9 InvalidType(String),
10 /// Not found.
11 #[error("not found")]
12 NotFound,
13 /// Anchor Error.
14 #[error(transparent)]
15 Anchor(#[from] anchor_lang::prelude::Error),
16}
17
18impl DecodeError {
19 /// Create a custom error.
20 pub fn custom(msg: impl ToString) -> Self {
21 Self::Custom(msg.to_string())
22 }
23}