mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
async-serial.rs and serial.rs to reflect this change. updated all files with new error handling.
31 lines
969 B
Rust
31 lines
969 B
Rust
use std::fmt;
|
|
|
|
/// Returns the relevant network error if a program fails.
|
|
pub type NetResult<T> = std::result::Result<T, NetError>;
|
|
|
|
/// An enum representing the main network errors.
|
|
#[derive(Debug, Clone)]
|
|
pub enum NetError {
|
|
OperationFailed,
|
|
ConnectFailed,
|
|
ConnectTimeout,
|
|
ChannelStopped,
|
|
ChannelTimeout,
|
|
ServiceStopped,
|
|
}
|
|
|
|
impl std::error::Error for NetError {}
|
|
|
|
impl fmt::Display for NetError {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
|
|
match *self {
|
|
NetError::OperationFailed => f.write_str("Operation failed"),
|
|
NetError::ConnectFailed => f.write_str("Connection failed"),
|
|
NetError::ConnectTimeout => f.write_str("Connection timed out"),
|
|
NetError::ChannelStopped => f.write_str("Channel stopped"),
|
|
NetError::ChannelTimeout => f.write_str("Channel timed out"),
|
|
NetError::ServiceStopped => f.write_str("Service stopped"),
|
|
}
|
|
}
|
|
}
|