This repository was archived by the owner on Feb 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use lightning::ln::peer_handler::PeerHandleError;
88use lightning_invoice:: ParseOrSemanticError ;
99use lightning_rapid_gossip_sync:: GraphSyncError ;
1010use lightning_transaction_sync:: TxSyncError ;
11+ use log:: error;
1112use nostr:: nips:: nip05;
1213use std:: string:: FromUtf8Error ;
1314use thiserror:: Error ;
@@ -179,7 +180,7 @@ pub enum MutinyError {
179180 #[ error( "Failed to connect to a federation." ) ]
180181 FederationConnectionFailed ,
181182 #[ error( transparent) ]
182- Other ( # [ from ] anyhow:: Error ) ,
183+ Other ( anyhow:: Error ) ,
183184}
184185
185186#[ derive( Error , Debug ) ]
@@ -585,3 +586,15 @@ impl From<payjoin::send::ResponseError> for MutinyError {
585586 Self :: PayjoinResponse ( e)
586587 }
587588}
589+
590+ impl From < anyhow:: Error > for MutinyError {
591+ fn from ( e : anyhow:: Error ) -> Self {
592+ error ! ( "Got unhandled error: {e}" ) ;
593+ // handle fedimint anyhow errors
594+ match e. to_string ( ) . as_str ( ) {
595+ "Insufficient balance" => Self :: InsufficientBalance ,
596+ "MissingInvoiceAmount" => Self :: BadAmountError ,
597+ _ => Self :: Other ( e) ,
598+ }
599+ }
600+ }
Original file line number Diff line number Diff line change @@ -228,15 +228,7 @@ impl From<MutinyError> for MutinyJsError {
228228 MutinyError :: TokenAlreadySpent => MutinyJsError :: TokenAlreadySpent ,
229229 MutinyError :: FederationRequired => MutinyJsError :: FederationRequired ,
230230 MutinyError :: FederationConnectionFailed => MutinyJsError :: FederationConnectionFailed ,
231- MutinyError :: Other ( e) => {
232- error ! ( "Got unhandled error: {e}" ) ;
233- // FIXME: For some unknown reason, InsufficientBalance is being returned as `Other`
234- if e. to_string ( ) . starts_with ( "Insufficient balance" ) {
235- MutinyJsError :: InsufficientBalance
236- } else {
237- MutinyJsError :: UnknownError
238- }
239- }
231+ MutinyError :: Other ( _) => MutinyJsError :: UnknownError ,
240232 MutinyError :: SubscriptionClientNotConfigured => {
241233 MutinyJsError :: SubscriptionClientNotConfigured
242234 }
You can’t perform that action at this time.
0 commit comments