xrpl/asynch/
exceptions.rs1use thiserror_no_std::Error;
2
3#[cfg(any(feature = "json-rpc", feature = "websocket"))]
4use super::clients::exceptions::XRPLClientException;
5#[cfg(feature = "helpers")]
6use super::{
7 transaction::exceptions::{XRPLSubmitAndWaitException, XRPLTransactionHelperException},
8 wallet::exceptions::XRPLFaucetException,
9};
10#[cfg(feature = "wallet")]
11use crate::wallet::exceptions::XRPLWalletException;
12#[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
15use crate::{
16 core::exceptions::XRPLCoreException,
17 models::transactions::exceptions::XRPLTransactionFieldException,
18 signing::exceptions::{XRPLMultisignException, XRPLSignTransactionException},
19 utils::exceptions::XRPLUtilsException,
20};
21use crate::{models::XRPLModelException, XRPLSerdeJsonError};
22
23pub type XRPLHelperResult<T, E = XRPLHelperException> = core::result::Result<T, E>;
24
25#[derive(Debug, Error)]
26pub enum XRPLHelperException {
27 #[cfg(feature = "wallet")]
28 #[error("XRPL Wallet error: {0}")]
29 XRPLWalletError(#[from] XRPLWalletException),
30 #[cfg(feature = "helpers")]
31 #[error("XRPL Faucet error: {0}")]
32 XRPLFaucetError(#[from] XRPLFaucetException),
33 #[cfg(feature = "helpers")]
34 #[error("XRPL Transaction Helper error: {0}")]
35 XRPLTransactionHelperError(#[from] XRPLTransactionHelperException),
36 #[error("XRPL Model error: {0}")]
37 XRPLModelError(#[from] XRPLModelException),
38 #[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
39 #[error("XRPL Core error: {0}")]
40 XRPLCoreError(#[from] XRPLCoreException),
41 #[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
42 #[error("XRPL Transaction Field error: {0}")]
43 XRPLTransactionFieldError(#[from] XRPLTransactionFieldException),
44 #[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
45 #[error("XRPL Utils error: {0}")]
46 XRPLUtilsError(#[from] XRPLUtilsException),
47 #[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
48 #[error("XRPL MultiSign error: {0}")]
49 XRPLMultiSignError(#[from] XRPLMultisignException),
50 #[cfg(all(feature = "core", feature = "models", feature = "wallet"))]
51 #[error("XRPL Sign Transaction error: {0}")]
52 XRPLSignTransactionError(#[from] XRPLSignTransactionException),
53 #[cfg(any(feature = "json-rpc", feature = "websocket"))]
54 #[error("XRPL Client error: {0}")]
55 XRPLClientError(#[from] XRPLClientException),
56 #[error("serde_json error: {0}")]
57 XRPLSerdeJsonError(#[from] XRPLSerdeJsonError),
58 #[error("From hex error: {0}")]
59 FromHexError(#[from] hex::FromHexError),
60 #[cfg(feature = "std")]
61 #[error("URL parse error: {0}")]
62 UrlParseError(#[from] url::ParseError),
63}
64
65impl From<serde_json::Error> for XRPLHelperException {
66 fn from(error: serde_json::Error) -> Self {
67 XRPLHelperException::XRPLSerdeJsonError(XRPLSerdeJsonError::SerdeJsonError(error))
68 }
69}
70
71#[cfg(feature = "helpers")]
76impl From<XRPLSubmitAndWaitException> for XRPLHelperException {
77 fn from(error: XRPLSubmitAndWaitException) -> Self {
78 XRPLHelperException::XRPLTransactionHelperError(
79 XRPLTransactionHelperException::XRPLSubmitAndWaitError(error),
80 )
81 }
82}