notecrumbs

a nostr opengraph server build on nostrdb and egui
git clone git://jb55.com/notecrumbs
Log | Files | Refs | README | LICENSE

commit cf6724bc57b58dc872e34443792339ede33ca1a9
parent eda44cdc9319d07abe89974825f382deaf616829
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 17 Dec 2023 13:23:44 -0800

error: add a few more error types

we will need this in the following commits

Diffstat:
Msrc/error.rs | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/error.rs b/src/error.rs @@ -1,21 +1,38 @@ use nostr_sdk::nips::nip19; use std::array::TryFromSliceError; use std::fmt; +use tokio::sync::broadcast::error::RecvError; #[derive(Debug)] pub enum Error { Nip19(nip19::Error), Http(hyper::http::Error), Nostrdb(nostrdb::Error), + NostrClient(nostr_sdk::client::Error), + Recv(RecvError), + NotFound, + InvalidNip19, SliceErr, } +impl From<RecvError> for Error { + fn from(err: RecvError) -> Self { + Error::Recv(err) + } +} + impl From<TryFromSliceError> for Error { fn from(_: TryFromSliceError) -> Self { Error::SliceErr } } +impl From<nostr_sdk::client::Error> for Error { + fn from(err: nostr_sdk::client::Error) -> Self { + Error::NostrClient(err) + } +} + impl From<nip19::Error> for Error { fn from(err: nip19::Error) -> Self { Error::Nip19(err) @@ -41,6 +58,10 @@ impl fmt::Display for Error { Error::Nip19(e) => write!(f, "Nip19 error: {}", e), Error::Http(e) => write!(f, "HTTP error: {}", e), Error::Nostrdb(e) => write!(f, "Nostrdb error: {}", e), + Error::NostrClient(e) => write!(f, "Nostr client error: {}", e), + Error::NotFound => write!(f, "Not found"), + Error::Recv(e) => write!(f, "Recieve error: {}", e), + Error::InvalidNip19 => write!(f, "Invalid nip19 object"), Error::SliceErr => write!(f, "Array slice error"), } }