xrpl_ws_client/
error.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4// #TODO: Connection
5
6#[derive(Error, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub enum Error {
8    #[error("internal error: {0}")]
9    Internal(String),
10    #[error("malformed JSON payload: {0}")]
11    MalformedJSON(String),
12}
13
14impl From<tokio_tungstenite::tungstenite::Error> for Error {
15    fn from(e: tokio_tungstenite::tungstenite::Error) -> Self {
16        Self::Internal(e.to_string())
17    }
18}
19
20impl From<serde_json::Error> for Error {
21    fn from(e: serde_json::Error) -> Self {
22        Self::MalformedJSON(e.to_string())
23    }
24}