Skip to main content

cbe_sdk/
transport.rs

1//! Defines the [`TransportError`] type.
2
3#![cfg(feature = "full")]
4
5use {crate::transaction::TransactionError, std::io, thiserror::Error};
6
7#[derive(Debug, Error)]
8pub enum TransportError {
9    #[error("transport io error: {0}")]
10    IoError(#[from] io::Error),
11    #[error("transport transaction error: {0}")]
12    TransactionError(#[from] TransactionError),
13    #[error("transport custom error: {0}")]
14    Custom(String),
15}
16
17impl TransportError {
18    pub fn unwrap(&self) -> TransactionError {
19        if let TransportError::TransactionError(err) = self {
20            err.clone()
21        } else {
22            panic!("unexpected transport error")
23        }
24    }
25}
26
27pub type Result<T> = std::result::Result<T, TransportError>;