typhoon_errors/
default_custom.rs

1use pinocchio::program_error::{ProgramError, ToStr};
2
3pub struct CustomError;
4
5impl TryFrom<u32> for CustomError {
6    type Error = ProgramError;
7
8    fn try_from(value: u32) -> Result<Self, Self::Error> {
9        match value {
10            200 => Ok(CustomError),
11            _ => Err(ProgramError::InvalidArgument),
12        }
13    }
14}
15
16impl ToStr for CustomError {
17    fn to_str<E>(&self) -> &'static str
18    where
19        E: 'static + ToStr + TryFrom<u32>,
20    {
21        "Error: Custom error"
22    }
23}
24
25impl From<CustomError> for u32 {
26    fn from(_: CustomError) -> Self {
27        200
28    }
29}