Skip to content

Commit 927f1e7

Browse files
committed
add try && catch for errors
1 parent 3974600 commit 927f1e7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/stellar_client/lib/src/client.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,15 @@ class Client {
364364
}
365365
throw Exception('Balance with asset code ${currency} not found.');
366366
});
367-
// check that receiver account exists
368-
final balance = await getBalanceByAccountID(
369-
network: _network, accountId: destinationAddress);
367+
List<BalanceInfo> balance = [];
368+
try {
369+
// check that receiver account exists
370+
balance = await getBalanceByAccountID(
371+
network: _network, accountId: destinationAddress);
372+
} catch (e) {
373+
throw Exception('Receiver account does not exist.');
374+
}
375+
370376
// check that asset exists
371377
var specificBalance = balance.firstWhere(
372378
(balance) => balance.assetCode == currency,

0 commit comments

Comments
 (0)