@@ -667,16 +667,15 @@ class Client {
667
667
final SubmitTransactionResponse response =
668
668
await _sdk.submitTransaction (transaction);
669
669
if (! response.success) {
670
- if (response.extras? .resultCodes? .operationsResultCodes
671
- ? .contains ('op_low_reserve' ) ==
672
- true ) {
673
- throw Exception ('Transaction failed due to low reserve.' );
674
- }
675
- logger.e ('Transaction failed with result: ${response .resultXdr }' );
676
- return false ;
670
+ throw StellarBalanceException .fromOperationResult (
671
+ response.extras? .resultCodes? .operationsResultCodes,
672
+ response.resultXdr,
673
+ );
677
674
}
678
675
679
676
return true ;
677
+ } on StellarBalanceException catch (_) {
678
+ rethrow ;
680
679
} catch (error) {
681
680
throw Exception ('Transaction failed due to: ${error .toString ()}' );
682
681
}
@@ -712,15 +711,14 @@ class Client {
712
711
final SubmitTransactionResponse response =
713
712
await _sdk.submitTransaction (transaction);
714
713
if (! response.success) {
715
- if (response.extras? .resultCodes? .operationsResultCodes
716
- ? .contains ('op_low_reserve' ) ==
717
- true ) {
718
- throw Exception ('Transaction failed due to low reserve.' );
719
- }
720
- logger.e ('Transaction failed with result: ${response .resultXdr }' );
721
- return false ;
714
+ throw StellarBalanceException .fromOperationResult (
715
+ response.extras? .resultCodes? .operationsResultCodes,
716
+ response.resultXdr,
717
+ );
722
718
}
723
719
return true ;
720
+ } on StellarBalanceException catch (_) {
721
+ rethrow ;
724
722
} catch (error) {
725
723
throw Exception ('Transaction failed due to: ${error .toString ()}' );
726
724
}
@@ -766,15 +764,14 @@ class Client {
766
764
final SubmitTransactionResponse response =
767
765
await _sdk.submitTransaction (transaction);
768
766
if (! response.success) {
769
- if (response.extras? .resultCodes? .operationsResultCodes
770
- ? .contains ('op_low_reserve' ) ==
771
- true ) {
772
- throw Exception ('Transaction failed due to low reserve.' );
773
- }
774
- logger.e ('Transaction failed with result: ${response .resultXdr }' );
775
- return false ;
767
+ throw StellarBalanceException .fromOperationResult (
768
+ response.extras? .resultCodes? .operationsResultCodes,
769
+ response.resultXdr,
770
+ );
776
771
}
777
772
return true ;
773
+ } on StellarBalanceException catch (_) {
774
+ rethrow ;
778
775
} catch (error) {
779
776
throw Exception ('Transaction failed due to: ${error .toString ()}' );
780
777
}
0 commit comments