mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Error type
This commit is contained in:
parent
3988efce54
commit
52a94eb32c
47
src/error.rs
Normal file
47
src/error.rs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
use crate::comms::BusMessage;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum Error {
|
||||||
|
#[error("Error broadcasting: {0}")]
|
||||||
|
BroadcastSend(#[from] tokio::sync::broadcast::error::SendError<BusMessage>),
|
||||||
|
|
||||||
|
#[error("Error receiving broadcast: {0}")]
|
||||||
|
BroadcastReceive(#[from] tokio::sync::broadcast::error::RecvError),
|
||||||
|
|
||||||
|
#[error("Error: {0}")]
|
||||||
|
General(String),
|
||||||
|
|
||||||
|
#[error("Task join error: {0}")]
|
||||||
|
JoinError(#[from] tokio::task::JoinError),
|
||||||
|
|
||||||
|
#[error("Error sending mpsc: {0}")]
|
||||||
|
MpscSend(#[from] tokio::sync::mpsc::error::SendError<BusMessage>),
|
||||||
|
|
||||||
|
#[error("Nostr: {0}")]
|
||||||
|
Nostr(#[from] nostr_proto::Error),
|
||||||
|
|
||||||
|
#[error("I/O Error: {0}")]
|
||||||
|
Io(#[from] std::io::Error),
|
||||||
|
|
||||||
|
#[error("Bad integer: {0}")]
|
||||||
|
ParseInt(#[from] std::num::ParseIntError),
|
||||||
|
|
||||||
|
#[error("SerdeJson Error: {0}")]
|
||||||
|
SerdeJson(#[from] serde_json::Error),
|
||||||
|
|
||||||
|
#[error("SQL: {0}")]
|
||||||
|
Sql(#[from] rusqlite::Error),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<String> for Error {
|
||||||
|
fn from(s: String) -> Error {
|
||||||
|
Error::General(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&str> for Error {
|
||||||
|
fn from(s: &str) -> Error {
|
||||||
|
Error::General(s.to_string())
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
mod comms;
|
mod comms;
|
||||||
|
mod error;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
|
Loading…
Reference in New Issue
Block a user