1use serde::{Deserialize, Serialize};
2use std::fmt::{self, Debug, Display, Formatter};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct ResponseError {
6 pub err: String,
7 pub status: u16,
8}
9
10impl Display for ResponseError {
11 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
12 Debug::fmt(&format!("status: {} {}", &self.err, &self.status), f)
13 }
14}
15
16
17#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
18pub enum LNError {
19 HTTPError(String),
20 HTTPResponseError(ResponseError),
21 StrikeError(String),
22 JsonError(String),
23}
24
25impl Display for LNError {
26 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
27 Debug::fmt(&self, f)
28 }
29}
30
31impl From<reqwest::Error> for LNError {
32 fn from(err: reqwest::Error) -> Self {
33 LNError::HTTPError(err.to_string())
34 }
35}