1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::sync::PoisonError;
use borsh::{BorshSerialize,BorshDeserialize};

#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)]
pub enum RpcResponseError {
    NoData,
    PoisonError,
    NonBorshRequest,
    NonSerdeRequest,
    ReqDeserialize,
    RespSerialize,
    Data(Vec<u8>),
    Text(String),
}

impl From<std::io::Error> for RpcResponseError {
    fn from(_err: std::io::Error) -> Self {
        RpcResponseError::RespSerialize
    }
}

impl<T> From<PoisonError<T>> for RpcResponseError {
    fn from(_error: PoisonError<T>) -> RpcResponseError {
        RpcResponseError::PoisonError
    }
}