IronForce is a decentralized network, Degeon is a messenger built on it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
1.4 KiB

use alloc::format;
use alloc::string::String;
use core::fmt::Debug;
/// An enum for all errors that may occur
#[derive(Clone, PartialEq, Debug)]
pub enum IFError {
/// An error that was created in some dependency and then converted to `IFError`
General(String),
/// A tunnel satisfying some conditions has not been found
TunnelNotFound,
/// Could not establish a connection
CouldNotConnect,
/// Error during serialization
SerializationError(String),
/// Error in rsa
CryptoError(String),
/// Error in std::io
IoError(String),
}
// impl<T: Debug + core_error::Error> From<T> for IFError {
// /// Convert from other error
// fn from(e: T) -> Self {
// Self::General(format!("{:?}", e))
// }
// }
#[cfg(feature = "std")]
impl From<std::io::Error> for IFError {
fn from(e: std::io::Error) -> Self {
Self::IoError(format!("{:?}", e))
}
}
impl From<serde_cbor::Error> for IFError {
fn from(e: serde_cbor::Error) -> Self {
Self::SerializationError(format!("{:?}", e))
}
}
impl From<serde_json::Error> for IFError {
fn from(e: serde_json::Error) -> Self {
Self::SerializationError(format!("{:?}", e))
}
}
impl From<rsa::errors::Error> for IFError {
fn from(e: rsa::errors::Error) -> Self {
Self::CryptoError(format!("{:?}", e))
}
}
pub type IFResult<T> = Result<T, IFError>;