start centralizing custom exceptions

This commit is contained in:
julian 2023-01-20 12:25:32 -06:00
parent 5c66b0380b
commit c1182f61bc
8 changed files with 31 additions and 22 deletions

View file

@ -0,0 +1,5 @@
import 'package:stackwallet/exceptions/sw_exception.dart';
class AddressException extends SWException {
AddressException(super.message);
}

View file

@ -0,0 +1,11 @@
// generic stack wallet exception which all other custom exceptions should
// extend from
class SWException with Exception {
SWException(this.message);
final String message;
@override
toString() => message;
}

View file

@ -0,0 +1,5 @@
import 'package:stackwallet/exceptions/sw_exception.dart';
class InsufficientBalanceException extends SWException {
InsufficientBalanceException(super.message);
}

View file

@ -0,0 +1,5 @@
import 'package:stackwallet/exceptions/sw_exception.dart';
class PaynymSendException extends SWException {
PaynymSendException(super.message);
}

View file

@ -1,14 +1,10 @@
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:stackwallet/exceptions/address/address_exception.dart';
import 'package:stackwallet/models/isar/models/address/crypto_currency_address.dart'; import 'package:stackwallet/models/isar/models/address/crypto_currency_address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
part 'address.g.dart'; part 'address.g.dart';
class AddressException extends SWException {
AddressException(super.message);
}
@Collection(accessor: "addresses") @Collection(accessor: "addresses")
class Address extends CryptoCurrencyAddress { class Address extends CryptoCurrencyAddress {
Address({ Address({

View file

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart';
import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart';

View file

@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart';
import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart';

View file

@ -8,6 +8,8 @@ import 'package:bitcoindart/src/utils/constants/op.dart' as op;
import 'package:bitcoindart/src/utils/script.dart' as bscript; import 'package:bitcoindart/src/utils/script.dart' as bscript;
import 'package:isar/isar.dart'; import 'package:isar/isar.dart';
import 'package:pointycastle/digests/sha256.dart'; import 'package:pointycastle/digests/sha256.dart';
import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart';
import 'package:stackwallet/exceptions/wallet/paynym_send_exception.dart';
import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/hive/db.dart';
import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart';
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
@ -16,23 +18,6 @@ import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
class SWException with Exception {
SWException(this.message);
final String message;
@override
toString() => message;
}
class InsufficientBalanceException extends SWException {
InsufficientBalanceException(super.message);
}
class PaynymSendException extends SWException {
PaynymSendException(super.message);
}
extension PayNym on DogecoinWallet { extension PayNym on DogecoinWallet {
// fetch or generate this wallet's bip47 payment code // fetch or generate this wallet's bip47 payment code
Future<PaymentCode> getPaymentCode() async { Future<PaymentCode> getPaymentCode() async {