diff --git a/mutiny-core/src/error.rs b/mutiny-core/src/error.rs index 89f7640d5..5fbce3cd6 100644 --- a/mutiny-core/src/error.rs +++ b/mutiny-core/src/error.rs @@ -182,6 +182,9 @@ pub enum MutinyError { /// Failed to connect to a federation. #[error("Failed to connect to a federation.")] FederationConnectionFailed, + /// Fedimint transaction too large + #[error("Error constructing fedimint transaction, try lowering the amount.")] + FederationTxTooLarge, #[error(transparent)] Other(anyhow::Error), } @@ -270,6 +273,7 @@ impl PartialEq for MutinyError { (Self::TokenAlreadySpent, Self::TokenAlreadySpent) => true, (Self::FederationRequired, Self::FederationRequired) => true, (Self::FederationConnectionFailed, Self::FederationConnectionFailed) => true, + (Self::FederationTxTooLarge, Self::FederationTxTooLarge) => true, (Self::Other(e), Self::Other(e2)) => e.to_string() == e2.to_string(), _ => false, } @@ -601,7 +605,13 @@ impl From for MutinyError { match e.to_string().as_str() { "Insufficient balance" => Self::InsufficientBalance, "MissingInvoiceAmount" => Self::BadAmountError, - _ => Self::Other(e), + "Federation didn't return peg-out fees" => Self::FederationConnectionFailed, + "The generated transaction would be rejected by the federation for being too large." => Self::FederationTxTooLarge, + str => if str.starts_with("Address isn't compatible with the federation's network") { + Self::IncorrectNetwork + } else { + Self::Other(e) + }, } } } diff --git a/mutiny-wasm/src/error.rs b/mutiny-wasm/src/error.rs index 4297049f4..0e06d4c9d 100644 --- a/mutiny-wasm/src/error.rs +++ b/mutiny-wasm/src/error.rs @@ -177,6 +177,9 @@ pub enum MutinyJsError { /// Failed to connect to a federation. #[error("Failed to connect to a federation.")] FederationConnectionFailed, + /// Fedimint transaction too large + #[error("Error constructing fedimint transaction, try lowering the amount.")] + FederationTxTooLarge, /// Unknown error. #[error("Unknown Error")] UnknownError, @@ -234,6 +237,7 @@ impl From for MutinyJsError { MutinyError::TokenAlreadySpent => MutinyJsError::TokenAlreadySpent, MutinyError::FederationRequired => MutinyJsError::FederationRequired, MutinyError::FederationConnectionFailed => MutinyJsError::FederationConnectionFailed, + MutinyError::FederationTxTooLarge => MutinyJsError::FederationTxTooLarge, MutinyError::Other(_) => MutinyJsError::UnknownError, MutinyError::SubscriptionClientNotConfigured => { MutinyJsError::SubscriptionClientNotConfigured