nostr_browser_signer_proxy/
error.rs1use std::{fmt, io};
8
9use hyper::http;
10use nostr::event;
11use tokio::sync::oneshot::error::RecvError;
12
13#[derive(Debug)]
15pub enum Error {
16 Io(io::Error),
18 Http(http::Error),
20 Json(serde_json::Error),
22 Event(event::Error),
24 OneShotRecv(RecvError),
26 Generic(String),
28 Timeout,
30 Shutdown,
32}
33
34impl std::error::Error for Error {}
35
36impl fmt::Display for Error {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 match self {
39 Self::Io(e) => write!(f, "{e}"),
40 Self::Http(e) => write!(f, "{e}"),
41 Self::Json(e) => write!(f, "{e}"),
42 Self::Event(e) => write!(f, "{e}"),
43 Self::OneShotRecv(e) => write!(f, "{e}"),
44 Self::Generic(e) => write!(f, "{e}"),
45 Self::Timeout => write!(f, "timeout"),
46 Self::Shutdown => write!(f, "server is shutdown"),
47 }
48 }
49}
50
51impl From<io::Error> for Error {
52 fn from(e: io::Error) -> Self {
53 Self::Io(e)
54 }
55}
56
57impl From<http::Error> for Error {
58 fn from(e: http::Error) -> Self {
59 Self::Http(e)
60 }
61}
62
63impl From<serde_json::Error> for Error {
64 fn from(e: serde_json::Error) -> Self {
65 Self::Json(e)
66 }
67}
68
69impl From<event::Error> for Error {
70 fn from(e: event::Error) -> Self {
71 Self::Event(e)
72 }
73}
74
75impl From<RecvError> for Error {
76 fn from(e: RecvError) -> Self {
77 Self::OneShotRecv(e)
78 }
79}