Skip to content

Commit

Permalink
add non_exhaustive to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LimpidCrypto committed Oct 31, 2024
1 parent 2ad675c commit 5c9a9a6
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/asynch/clients/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::XRPLWebSocketException;
pub type XRPLClientResult<T, E = XRPLClientException> = core::result::Result<T, E>;

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum XRPLClientException {
#[error("serde_json error: {0}")]
XRPLSerdeJsonError(#[from] XRPLSerdeJsonError),
Expand Down
1 change: 1 addition & 0 deletions src/asynch/clients/json_rpc/exceptions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use thiserror_no_std::Error;

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum XRPLJsonRpcException {
#[error("Reqwless error: {0:?}")]
ReqwlessError(#[from] reqwless::Error),
Expand Down
1 change: 1 addition & 0 deletions src/asynch/clients/websocket/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use futures::channel::oneshot::Canceled;
use thiserror_no_std::Error;

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum XRPLWebSocketException {
// FramerError
#[error("I/O error: {0:?}")]
Expand Down
3 changes: 3 additions & 0 deletions src/asynch/transaction/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloc::string::String;
use thiserror_no_std::Error;

#[derive(Error, Debug, PartialEq)]
#[non_exhaustive]
pub enum XRPLTransactionHelperException {
#[error("Fee of {0:?} Drops is much higher than a typical XRP transaction fee. This may be a mistake. If intentional, please use `check_fee = false`")]
FeeUnusuallyHigh(String),
Expand All @@ -18,6 +19,7 @@ pub enum XRPLTransactionHelperException {
}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLSignTransactionException {
#[error("{0:?} value does not match X-Address tag")]
TagFieldMismatch(String),
Expand All @@ -28,6 +30,7 @@ pub enum XRPLSignTransactionException {
}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLSubmitAndWaitException {
#[error("Transaction submission failed: {0}")]
SubmissionFailed(String),
Expand Down
1 change: 1 addition & 0 deletions src/asynch/wallet/exceptions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use thiserror_no_std::Error;

#[derive(Error, PartialEq, Debug)]
#[non_exhaustive]
pub enum XRPLFaucetException {
#[error(
"Cannot fund an account on an issuing chain. Accounts must be created via the bridge."
Expand Down
1 change: 1 addition & 0 deletions src/models/results/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use thiserror_no_std::Error;
use super::XRPLOtherResult;

#[derive(Debug, PartialEq, Error)]
#[non_exhaustive]
pub enum XRPLResultException {
#[error("Response error: {0}")]
ResponseError(String),
Expand Down
5 changes: 5 additions & 0 deletions src/models/transactions/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pub enum XRPLPaymentException {
impl alloc::error::Error for XRPLPaymentException {}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLSignerListSetException {
/// A field was defined that another field definition would delete.
#[error("The value of the field `{field1:?}` can not be defined with the field `{field2:?}` because it would cause the deletion of `{field1:?}`")]
Expand Down Expand Up @@ -151,6 +152,7 @@ pub enum XRPLSignerListSetException {
impl alloc::error::Error for XRPLSignerListSetException {}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLXChainClaimException {
#[error("`amount` must match either `locking_chain_issue` or `issuing_chain_issue`")]
AmountMismatch,
Expand All @@ -160,6 +162,7 @@ pub enum XRPLXChainClaimException {
impl alloc::error::Error for XRPLXChainClaimException {}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLXChainCreateBridgeException {
#[error("Cannot have the same door accounts on the locking and issuing chain")]
SameDoorAccounts,
Expand All @@ -181,6 +184,7 @@ pub enum XRPLXChainCreateBridgeException {
impl alloc::error::Error for XRPLXChainCreateBridgeException {}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLXChainCreateClaimIDException {
#[error("`other_chain_source` must be a valid XRPL address")]
OtherChainSourceIsInvalid,
Expand All @@ -190,6 +194,7 @@ pub enum XRPLXChainCreateClaimIDException {
impl alloc::error::Error for XRPLXChainCreateClaimIDException {}

#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum XRPLXChainModifyBridgeException {
#[error("Must either change `signature_reward`, change `min_account_create_amount`, or clear `min_account_create_amount`")]
MustChangeOrClear,
Expand Down
1 change: 1 addition & 0 deletions src/transaction/exceptions.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use thiserror_no_std::Error;

#[derive(Debug, PartialEq, Error)]
#[non_exhaustive]
pub enum XRPLMultisignException {
#[error("No signers set in the transaction. Use `sign` function with `multisign = true`.")]
NoSigners,
Expand Down
2 changes: 2 additions & 0 deletions src/utils/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::XRPLSerdeJsonError;
pub type XRPLUtilsResult<T, E = XRPLUtilsException> = core::result::Result<T, E>;

#[derive(Debug, PartialEq, Error)]
#[non_exhaustive]
pub enum XRPLUtilsException {
#[error("XRPL Time Range error: {0}")]
XRPLTimeRangeError(#[from] XRPLTimeRangeException),
Expand All @@ -26,6 +27,7 @@ pub enum XRPLUtilsException {
}

#[derive(Debug, Clone, PartialEq, Error)]
#[non_exhaustive]
pub enum XRPLTimeRangeException {
#[error("Invalid time before epoch (min: {min} found: {found})")]
InvalidTimeBeforeEpoch { min: i64, found: i64 },
Expand Down
1 change: 1 addition & 0 deletions src/wallet/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::core::exceptions::XRPLCoreException;
pub type XRPLWalletResult<T, E = XRPLWalletException> = core::result::Result<T, E>;

#[derive(Debug, PartialEq, Error)]
#[non_exhaustive]
pub enum XRPLWalletException {
#[error("XRPL Core error: {0}")]
XRPLCoreError(#[from] XRPLCoreException),
Expand Down

0 comments on commit 5c9a9a6

Please sign in to comment.