nostrdb-rs

nostrdb in rust!
git clone git://jb55.com/nostrdb-rs
Log | Files | Refs | Submodules | README | LICENSE

commit 7c6ab4134fce4bb72cfcbdb3cbb07ca5c24bb15d
parent 49220498ff059835a44019e1591d3c71b0a8a4d9
Author: William Casarin <jb55@jb55.com>
Date:   Sat, 16 Dec 2023 16:24:55 -0800

error: make it a bit more friendly for other libs

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

diff --git a/src/error.rs b/src/error.rs @@ -1,3 +1,5 @@ +use std::fmt; + #[derive(Debug, Eq, PartialEq)] pub enum Error { DbOpenFailed, @@ -6,3 +8,18 @@ pub enum Error { NoteProcessFailed, TransactionFailed, } + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let s = match self { + Error::DbOpenFailed => "Open failed", + Error::NotFound => "Not found", + Error::DecodeError => "Decode error", + Error::NoteProcessFailed => "Note process failed", + Error::TransactionFailed => "Transaction failed", + }; + write!(f, "{}", s) + } +} + +impl std::error::Error for Error {}