Skip to content

Commit

Permalink
Handle receiver unrecoverable errors
Browse files Browse the repository at this point in the history
Receivers need to handle both switch errors or isolate errors. This change
takes the error handling out of the spawn try-catch, which would never receive
them and moves it into places where those errors would propagate.

Note that some of the switch errors like checkIsOwned might crop up
because of a wallet being improperly loaded, but for the time being we don't
have the granularity to distinguish between them.
  • Loading branch information
DanGould committed Jan 3, 2025
1 parent fd2fc86 commit 2248dc4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/_pkg/payjoin/manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,21 @@ class PayjoinManager {
// TODO PROPAGATE ERROR TO UI TOAST / TRANSACTION HISTORY
debugPrint(e.toString());
await _cleanupSession(receiver.id());
await _payjoinStorage
.markReceiverSessionUnrecoverable(receiver.id());
completer.complete(
Err(
e.toString(),
),
);
}
} else if (message is Err) {
} else if (message is SessionError) {
await _cleanupSession(receiver.id());
completer.complete(message);
if (message is UnrecoverableError) {
await _payjoinStorage
.markReceiverSessionUnrecoverable(receiver.id());
}
completer.complete(Err(message.toString()));
}
});

Expand All @@ -301,9 +307,6 @@ class PayjoinManager {

return completer.future;
} catch (e) {
if (e is UnrecoverableError) {
await _payjoinStorage.markReceiverSessionUnrecoverable(receiver.id());
}
return Err(
e.toString(),
title: 'Error occurred while receiving Payjoin',
Expand Down

0 comments on commit 2248dc4

Please sign in to comment.